akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    int n;
    vector<int> s;
    cin >> n;
    int sum = 0;
    rep(i,0,n){
        int ii;
        cin >> ii;
        s.push_back(ii);
        sum += ii;
    }
    sort(all(s));
    if(sum % 10){
        cout << sum << endl;
        return 0;
    }
    rep(i,0,n){
        if(s[i] % 10){
            cout << sum - s[i] << endl;
            return 0;
        }
    }

    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

void main() {
    int a,b,c,x,y;
    readf("%d %d %d %d %d\n",&a,&b,&c,&x,&y);

    long ans = 1145141919;
    foreach (k; 0 .. 10^^5+1) {
        long z = 2*c*k + a * max(0, x - k) + b * max(0, y - k);
        ans = min(ans, z);
    }

    writeln(ans);

    string _ = readln;
}

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

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> v(n);
    double ans =0;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    sort(v.begin(), v.end());
    ans += v[0];
    for(int i = 1; i < n; i++) {
        // cout << v[i] << endl;
        // cout << ans << endl;
        ans = (ans + v[i]) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int n;
   std::cin >> n;
   std::vector<Int> xs(n);
   rep(i,n) std::cin >> xs[i];
   std::sort(xs.begin(), xs.end());
   std::vector<Int> ys, zs;
   rep(i,n) {
      if( i == 0 or xs[i] != xs[i-1] ) {
         ys.emplace_back(xs[i]);
         zs.emplace_back(1);
      }
      else {
         zs.back() += 1;
      }
   }
   Int res = 0;
   rep(i,ys.size()) {
      if( zs[i] < ys[i] ) {
         res += zs[i];
      }
      else {
         res += zs[i] - ys[i];
      }
   }
   printf("%ld\n", res);
}


Measured memory_bytes: 2804
// at_abc156a.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;
int main()
{
    int n, k;cin >> n >> k;
    if (n >= 10) { cout << k << "\n"; }
    else {
        cout << k + 100 * (10 - n) << "\n";
    }
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 256
#include <stdio.h>

int n ,k, i, c, p;
int main() {
  scanf("%d%d\n", &n, &k); k = -2 * k;
  while(i++ < n)if((c = getchar_unlocked()) != p) k++, p = c;
  printf("%d",n - (k < 1 ? 1 : k));
  return 0;
}
  

Measured memory_bytes: 128
/**#include <bits/stdc++.h>
 using namespace std;
 int main(){
 long long X;
 cin >> X;
 long long P = 100, step = 0;
 while(P < X){
 P += P / 100;
 step++;
 }
 cout << step << endl;
 return 0;
 }



**/#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long
#define f(i, a, b) for(ll i = a;i<b; i++)
int main()
{

	ll x;
	cin>>x;
	ll i=0;
	ll s = 100;
	while(s<x)
    {
        s += (s/100);
    i++;
    }
    cout<<i;
    return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int K, T; cin >> K >> T;
	vector<int>a(T);
	rep(i, 0, T) {
		cin >> a[i];
	}
	int ans = 0;
	rep(i, 0, T) {
		if (K / 2 < a[i]) {
			int x = 2 * a[i] - K;
			ans += x - 1;
			break;
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	tmp = input.split("\n");
	
	var a = parseInt(tmp[0]);
	var b = parseInt(tmp[1]);
	var c = parseInt(tmp[2]);
	var d = parseInt(tmp[3]);
	var e = parseInt(tmp[4]);
	var k = parseInt(tmp[5]);
	var err = 0;
	
	if(b-a > k){ err++; }
	if(c-a > k){ err++; }
	if(d-a > k){ err++; }
	if(e-a > k){ err++; }
	if(c-b > k){ err++; }
	if(d-b > k){ err++; }
	if(e-b > k){ err++; }
	if(d-c > k){ err++; }
	if(e-c > k){ err++; }
	if(e-d > k){ err++; }
	
	if(err>=1){
		console.log(":(");
	}else{
		console.log("Yay!");
	}
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
	int n;
    cin >> n;
    bool OK = false;
	for (int j = 0; j <= n / 4; j++) {
		for (int k = 0; k <= n / 7; k++) {
			if (4 * j + 7 * k == n) OK = true;
		}
	}
	if (OK == false) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'
#define INF (1e18)

void solve() {
    int n, k;
    cin >> n >> k;

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

    auto it = lower_bound(v.begin(), v.end(), 0LL);
    int p = it - v.begin();
    ll ans = INF;
    for (int i = p-k+1; i < p; ++i) {
        if (i<0)
            continue;
        if (i+k-1>=n)
            break;
        ll d = v[i+k-1] - v[i];
        d += min(abs(v[i + k - 1]), abs(v[i]));
        ans = min(ans, d);
    }

    if (p-k>=0) {
        ans = min(ans, -v[p-k]);
    }
    if (p+k-1<n) {
        ans = min(ans, v[p+k-1]);
    }

    cout << ans << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
    solve();
}

Measured memory_bytes: 1024
a = int(input())
b = int(input())
c = int(input())
x = int(input())

index1 =0
count =0
while index1<a+1:
    sum1 =0
    index2=0
    sum1+=500*index1
    while index2<b+1:
        sum2=0
        index3=0
        sum2+=100*index2
        while index3<c+1:
            sum3=0
            sum3+=50*index3
            if sum1+sum2+sum3==x:
                count+=1
            index3+=1
        index2+=1
    index1+=1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    long long N;
    cin >> N;
    auto pf = prime_factorize(N);
    long long res = 0;
    for (auto p : pf) {
        long long e = p.second;
        long long tmp = 0, cur = 1;
        while (e >= cur) e -= cur++, ++tmp;
        res += tmp;
    }
    cout << res << endl;
}

Measured memory_bytes: 3644
# C - Poll

N = int(input())
D = {}
mx = 0
for _ in range(N):
    s = str(input())
    if s not in D:
        D[s] = 0
    D[s] += 1
    if mx < D[s]:
        mx = D[s]

for a in sorted([d for d in D if D[d] == mx]):
    print(a)


Measured memory_bytes: 32988
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int a;
	string s;
	cin>>a>>s;
	if(a>=3200) cout<<s;
	else cout<<"red";
}

Measured memory_bytes: 256
s = str(input())
q = int(input())

head = ''
back = ''
flg = 1
for _ in range(q):
    i = list(map(str, input().split()))
    if i[0] == '1':
        #head, back = back, head
        flg *= -1
    else:
        if i[1] == '1':
            if flg == 1:
                head = head + i[2]
            else:
                back = back + i[2]
        else:
            if flg == 1:
                back = back + i[2]
            else:
                head = head+ i[2]

if flg == 1:
    print(head[::-1]+s+back)
else:
    print(back[::-1]+s[::-1]+head)

Measured memory_bytes: 4340
MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


N, K = map(int, input().split())
modFacts, invs = prepare(N)

ans = 0
for k in range(min(K + 1, N)):
    num = (modFacts[N - 1] * invs[N - k - 1] * invs[k]) % MOD
    zero = (modFacts[N] * invs[k] * invs[N - k]) % MOD
    ans += (num * zero) % MOD
    ans %= MOD
print(ans)


Measured memory_bytes: 44012
#include <stdio.h>
int main()
{
int a=0, b=0;
scanf("%d",&a);
scanf("%d",&b);

if(-1000<=a&&b<=1000)
{
    if(a<b)
    {
        printf("a < b\n");
    }
    if(a>b)
    {
        printf("a > b\n");
    }
    if(a==b)
    {
        printf("a == b\n");
    }
}
return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
typedef long long ll;
using namespace std;

int main(void) {
	int k, res = 0;
	cin >> k;
	for (int i = 1;i <= k;i++) {
		if (i % 2 == 0) {
			for (int j = 1;j <= k;j++) {
				if (j % 2 == 1) {
					res++;
				}
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=20,mod=1000000007;
#define lowbit(i) (i&-i)
int n,m,k,ans,ycl[20],dp[N+1][1<<N],tong[N][N];
inline void add(int &a,int b){
	a=a+b>=mod?a+b-mod:a+b;
}
signed main(){
	n=read(); m=read(); k=read(); n--;
	memset(tong,-1,sizeof(tong));
	for(int i=1;i<=k;i++){
		int a=read(),b=read(),c=read();
		tong[a-1][b-1]=c;
	}
	dp[0][0]=1; ycl[0]=(1<<n)-1;
	for(int i=1;i<n;i++)ycl[i]=ycl[i-1]^(1<<(i-1));
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<(1<<n);k++){
				if(tong[i][j]!=1&&((k>>j&1)==0)){
					add(dp[j+1][k],dp[j][k]);
				}
				if(tong[i][j]!=0){
					int t=k&ycl[j];// cout<<i<<" "<<j<<" "<<k<<" "<<(k^lowbit(t)^(1<<j))<<endl;
					add(dp[j+1][k^lowbit(t)^(1<<j)],dp[j][k]);
				}
			}
		}
		swap(dp[n],dp[0]);
		//for(int j=0;j<(1<<n);j++)cout<<i<<" "<<j<<" "<<dp[0][j]<<endl;
		for(int j=1;j<=n;j++)memset(dp[j],0,sizeof(dp[j]));
	}
	for(int i=0;i<(1<<n);i++)ans=(ans+dp[0][i])%mod;
	cout<<ans<<endl;
}

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


int main() {
    ll x,y; cin >> x >> y;
    ll u=y/x;
    ll ans=0;
    while(u>0){
        u/=2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto as = readln.chomp.split.map!(to!int);
  int res = 1;
  foreach (a; as) {
    if (a % 2 == 0) {
      res *= 2;
    }
  }
  writeln(3^^n - res);
}


Measured memory_bytes: 256
import time
import random


class Problem:

    def __init__(self, D, s, c):
        self.last_days = [0] * 26
        self.D = D
        self.s = s
        self.c = c
        self.answer = [0] * self.D
        self.best_answer = [0] * self.D

    def scoring(self, day, ind):
        day_score = self.s[day][ind]
        minus_score = 0
        for i in range(26):
            if i != ind:
                minus_score += self.c[i] * (day + 1 - self.last_days[i])
        day_score -= minus_score
        return day_score

    def get_all_scores(self, day):
        """全ての選択肢のscoreを返す"""
        minus_score = 0
        all_scores = [0] * 26
        for i in range(26):
            if i == 0:
                for j in range(1, 26):
                    minus_score += self.c[j] * (day + 1 - self.last_days[j])
                all_scores[0] = self.s[day][0] - minus_score

            else:
                minus_score += self.c[i - 1] * (day + 1 - self.last_days[i - 1])
                minus_score -= self.c[i] * (day + 1 - self.last_days[i])
                all_scores[i] = self.s[day][i] - minus_score
        return all_scores

    def _strategy(self, day):
        ind = random.randint(0, 25)
        score = self.scoring(day, ind)
        return score, ind

    def solve(self):
        self.init()

        sum_score = 0
        for i in range(self.D):
            score, ind = self._strategy(i)
            self.last_days[ind] = i + 1
            self.answer[i] = ind
            sum_score += score
        return sum_score, self.answer

    def _strategy_perturbation(self):
        # ランダムに１日を取り出し、一番その日の期待コストが大きくなるよう変化させる
        # 貪欲法に摂動を加えてみる
        day = random.randint(0, 3)

        # scores = [self.scoring()]

        random.randint(0, 3)

    def solve_greed(self):
        self.init()

    def init(self):
        self.last_days = [0] * 26
        self.answer = [0] * self.D


def main():
    time_start = time.time()
    DO_TIME = 2 * 0.90
    D = int(input())
    c = list(map(int, input().split()))
    s = []

    for _ in range(D):
        s.append(list(map(int, input().split())))

    max_score = 0

    problem = Problem(D, s, c)
    ite = 0
    while time.time() - time_start < DO_TIME:
        ite += 1
        score, answer = problem.solve()

        if score > max_score:
            # print("hit")
            # print(max_score)
            max_score = score
            problem.best_answer = answer

    for i in range(D):
        problem.best_answer[i] += 1
        print(problem.best_answer[i])
    # print(ite)
    # print(max_answer)
    # print(max_score)
    # print(problem.get_all_scores(1))


main()


Measured memory_bytes: 88444
#include <iostream>
#include <vector>
#include <math.h>

int main()
{
	int N; std::cin >> N;
	std::vector<std::pair<long long, long long> > a(N);
	for(int i=0; i<N; i++)
	{
		std::cin >> a[i].first;
		std::cin >> a[i].second;
	}
	for(int i=1; i<N; i++)
	{
//		long long m = std::max(ceil((double)a[i-1].first/a[i].first), ceil((double)a[i-1].second/a[i].second));
		long long m = std::max(a[i-1].first/a[i].first+(a[i-1].first%a[i].first==0 ? 0 : 1), a[i-1].second/a[i].second+(a[i-1].second%a[i].second==0 ? 0 : 1));
		a[i].first *= m;
		a[i].second *= m;
	}
	std::cout << a.back().first+a.back().second << std::endl;
	return 0;
}

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

int main () {
  int s;
  cin >> s;
  int s1 = s/100;
  int s2 = s%100;

  bool MM1 = false;
  bool MM2 = false;
  if ((s1 > 0)&&(s1 < 13)) MM1 = true;
  if ((s2 > 0)&&(s2 < 13)) MM2 = true;
  
  if (MM1 && MM2) cout << "AMBIGUOUS" << endl;
  else if (MM1) cout << "MMYY" << endl;
  else if (MM2) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}

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

void calc(std::vector<double> first, std::vector<double> second) {
    double div;

    div = second[0] / first[0];
    second[0] = 0;
    second[1] -= first[1] * div;
    second[2] -= first[2] * div;
    second[2] /= second[1];
    second[1] = 1;

    first[2] -= first[1] * second[2];
    first[1] = 0;
    first[2] /= first[0];
    first[0] = 1;

    std::cout << std::fixed << std::setprecision(3) << first[2] << " " << second[2] << std::endl;
    return;
}

int main(void) {
    std::vector<double> first(3, 0);
    std::vector<double> second(3, 0);
    while(std::cin >> first[0]) {
        for (int i = 1; i < 3; i++) {
            std::cin >> first[i];
        }
        for (int i = 0; i < 3; i++) {
            std::cin >> second[i];
        } 
        calc(first, second);
    }
    return 0;
}

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

string zhihuchuan;

int main()
{
	cin>>zhihuchuan;
	int c=10000,f=-10000;
	for(int i=0;i<zhihuchuan.size();i++)
	{
		if(zhihuchuan[i]=='C')
		{
			c=i;
			break;
		}
	}
	for(int i=zhihuchuan.size()-1;i>=0;i--)
	{
		if(zhihuchuan[i]=='F')
		{
			f=i;
			break;
		}
	}
	if(c<f)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
n = int(input())
p = [[int(i) for i in input().split()] for i in range(n)]
p.sort(key=lambda x: x[2])
a,b,c = p[-1]
f = 0
for cx in range(101):
	for cy in range(101):
		h = c+abs(a-cx)+abs(b-cy)
		if all(k==max(h-abs(i-cx)-abs(j-cy),0) for i,j,k in p): f = 1
		if f: break
	if f: break
print(cx,cy,h)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N; string s; cin >> N >> s;
	rep(a,2){
		rep(b,2){
			string res(N+2,'.');
			res[0] = (a ? 'S' : 'W');
			res[1] = (b ? 'S' : 'W');
			for(int i=2;i<N+2;i++){
				res[i] = res[i-2];
				if(s[(i-1)%N] == 'x') res[i] ^= 'S'^'W';
				if(res[(i-1)%N] == 'W') res[i] ^= 'S'^'W';
			}
			if(res[0] == res[N] && res[1] == res[N+1]){
				cout << res.substr(0,N) << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 720
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP=pair<P, int>;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			ans[i]++;
		}
	}
	if (n != 1) ans[n]++;
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

signed main() {
	int a, b;
	cin >> a >> b;
	cout << max({ a + b,a - b,a * b }) << endl;
}

Measured memory_bytes: 256
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55

using namespace std;

  
unsigned int onesComplement(unsigned int n) 
{ 
   // Find number of bits in the given integer 
   int number_of_bits = floor(log2(n))+1; 
  
   // XOR the given integer with poe(2,  
   // number_of_bits-1 and print the result  
   return ((1 << number_of_bits) - 1) ^ n; 
} 

string binary(int num){
	string res="";
	while(num){
		if(num%2==0){
			res.pb('0');
		}else{
			res.pb('1');
		}
		num/=2;
	}
	reverse(res.begin(),res.end());
	return res;
}
int bin(string a){
	int res=0;
	int buf=1;
	for(int i=a.length()-1;i>=0;i--){
		int temp=a[i]-'0';
		res=res+ buf*temp;
		buf=buf*2;
	}
	return res;
}
unsigned int l,r;
unordered_set<int> s;
void allpos(string &a,int ind,int n){
	int ho=bin(a);
	if(ho>r){
		return;
	}
	if(ho>=(int)l)
	s.insert(ho);
	if(ind==n){
		return;
	}
	
	if(a[ind]=='0'){
		a[ind]='1';
		allpos(a,ind+1,n);
		a[ind]='0';
		allpos(a,ind+1,n);	
	}else{
		allpos(a,ind+1,n);
	}
	return;
}


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

    int w,h,n;cin>>w>>h>>n;

    int grid[h+1][w+1];

    for(int i=1;i<=h;i++){
    	for(int j=1;j<=w;j++){
    		grid[i][j]=0;
    	}
    }

    while(n--){
    	int x,y,a;cin>>x>>y>>a;
    	if(a==1){
    		for(int i=1;i<=h;i++){
    			for(int j=1;j<=x;j++){
    				grid[i][j]=1;
    			}
    		}
    	}else if(a==2){
    		for(int i=1;i<=h;i++){
    			for(int j=x+1;j<=w;j++){
    				grid[i][j]=1;
    			}
    		}
    	}else if(a==3){
    		for(int i=(h-y)+1;i<=h;i++){
    			for(int j=1;j<=w;j++){
    				grid[i][j]=1;
    			}
    		}
    	}else{
    		for(int i=1;i<=(h-y);i++){
    			for(int j=1;j<=w;j++){
    				grid[i][j]=1;
    			}
    		}
    	}
    	
    }

    int res=0;
    for(int i=1;i<=h;i++){
    	for(int j=1;j<=w;j++){
    		if(grid[i][j]==0)
    			res++;
    	}
    }
    
    cout<<res<<endl;
	return 0;
}

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

using Point=System.Tuple<long,long>;

public static class Program {
    public static void Main() {
        long h=long.Parse(Console.ReadLine());
        long ans=0;
        long coeff=1;
        while(1<=h){
            ans+=coeff;
            h/=2;
            coeff*=2;
        }
        Console.WriteLine(ans);
    }
}


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

int main( void )
{
    int x, a, b;
    cin >> x >> a >> b;
    if ( b <= a )
    {
        cout << "delicious" << endl;
    }
    else if ( b - a <= x )
    {
        cout << "safe" << endl;
    }
    else
    {
        cout << "dangerous" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

s = input()

for i in range(len(s)):
    if s[i] == 'A':
        a = i 
        break

for i in range(len(s)):
    if s[len(s)-1-i] == 'Z':
        b = len(s)-i-1
        break

print(b-a+1)


Measured memory_bytes: 3500
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())

A = make_divisors(N)
result = pow(10,12)
#print(A)
for i in A:
    #print(i)
    B = (N/i-1)+(i-1)
    #print(B)
    result = min(result,B)
    
print(int(result))

Measured memory_bytes: 3268
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int N;
  cin >> N;
  if (N >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;

}



Measured memory_bytes: 3648
package main

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

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func rs() string {
	sc.Scan()
	return sc.Text()
}

func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	var s string
	ctAB, ctTailA, ctHeadB, ctTailAHeadB := 0, 0, 0, 0
	for i := 0; i < n; i++ {
		s = rs()
		for j := 0; j < len(s)-1; j++ {
			if s[j] == 'A' && s[j+1] == 'B' {
				ctAB++
			}
		}
		if s[len(s)-1] == 'A' {
			ctTailA++
		}
		if s[0] == 'B' {
			ctHeadB++
		}
		if s[len(s)-1] == 'A' && s[0] == 'B' {
			ctTailAHeadB++
		}
	}

	ans := -1
	ans = ctAB + smaller(ctTailA, ctHeadB)
	if ctTailAHeadB != 0 && ctTailAHeadB == ctTailA && ctTailAHeadB == ctHeadB {
		ans--
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
n,x=map(int,input().split())
a=list(map(int,input().split()))
c=0
if a[0]>x:
    c+=a[0]-x
    a[0]=x
for i in range(1,n):
    if a[i]+a[i-1]>x:
        c+=a[i]+a[i-1]-x
        a[i]-=a[i]+a[i-1]-x
print(c)


Measured memory_bytes: 63856
#include <iostream>

#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define repd(i,x,n) for(int i=x;i<=n;i++)

using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
ll n;
ll a[maxn];
ll b[maxn];
ll c[maxn];
ll dp[maxn][5];

int main()
{
    gbtb;
    cin>>n;
    repd(i,1,n)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];
    repd(i,2,n)
    {
        dp[i][1]+=max(dp[i-1][2],dp[i-1][3])+a[i];
        dp[i][2]+=max(dp[i-1][1],dp[i-1][3])+b[i];
        dp[i][3]+=max(dp[i-1][1],dp[i-1][2])+c[i];
    }
    cout<<max(dp[n][3],max(dp[n][1],dp[n][2]));
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}

Measured memory_bytes: 14592
#include<stdio.h>

int main(void)
{
 int a,b,k,n,i;
 scanf("%d%d%d",&a,&b,&k);

 for(i=a;i<=b;i++){
   if((i<=a+k-1)||(i>=b-k+1))
     printf("%d\n",i);
 }
 return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a>=b)&&(a>=c))
    {
        if(b>=c)
        {
            printf("%d %d %d\n",c,b,a);
        }
        else
        {
            printf("%d %d %d\n",b,c,a);
        }
    }
    else if((b>=a)&&(b>=c))
    {
        if(a>=c)
        {
            printf("%d %d %d\n",c,a,b);
        }
        else
        {
            printf("%d %d %d\n",a,c,b);
        }
    }
    else if((c>=a)&&(c>=b))
    {
        if(a>=b)
        {
            printf("%d %d %d\n",b,a,c);
        }
        else
        {
            printf("%d %d %d\n",a,b,c);
        }
    }
    return 0;
}


Measured memory_bytes: 2040
import java.util.*;
import java.awt.geom.*;
import java.io.*;
public class Main{
    int [][] dp;
    int MAX = 1120;
    int K= 14;
    boolean [] isprime;
     
    private void doit(){
        Scanner sc = new Scanner(System.in);
         
        isprime = new boolean[MAX + 1];
        eratos();
         
        dp = new int[K + 1][MAX + 1];
        dp();
        while(true){
            int n = sc.nextInt();
            int k = sc.nextInt();
            if((n|k) == 0) break;
            System.out.println(dp[k][n]);
        }
    }
 
    private void dp() {
        for(int i = 1; i <= MAX; i++){
            dp[1][i] = isprime[i] ? 1 : 0;
        }
         
        for(int i = MAX; i >= 2; i--){
            if(! isprime[i]) continue;
            for(int j = MAX; j >= i; j--){
                for(int k = K - 1; k  >= 1; k--){
                    if(k == 1 && j == i) continue;
                    if(j + i > MAX) continue;
                    dp[k+1][j + i] += dp[k][j];
                }
            }
        }
    }
 
    private void eratos() {
        Arrays.fill(isprime, true);
        isprime[0] = false;
        isprime[1] = false;
        for(int i = 2; i * i <= MAX; i++){
            if(isprime[i]){
                for(int j = i * 2; j <= MAX; j+= i){
                    isprime[j] = false;
                }
            }
        }
         
    }
 
    public static void main(String [] args){
        new Main().doit();
    }
}

Measured memory_bytes: 12000
#include <iostream>

using namespace std;

int main(void)
{
	char a[100][100];
	int H, W;
	cin >> H >> W;

	for (int j = 0; j < H; j++){
		for (int i = 0; i < W; i++){
			cin >> a[j][i];
		}
	}


	for (int j = 0; j < H; j++){
		for (int i = 0; i < W; i++){
			if (a[j][i] == '#')
				break;
			if (i == W - 1)
				for (int k = 0; k < W; k++){
					a[j][k] = '*';
				}
		}
	}

	for (int i = 0; i < W; i++){
		for (int j = 0; j < H; j++){
			if (a[j][i] == '#')
				break;
			if (j == H - 1){
				for (int k = 0; k < H; k++){
					a[k][i] = '*';
				}
			}
		}
	}

	for (int j = 0; j < H; j++){
		for (int i = 0; i < W; i++){
			if (a[j][i] != '*')
				cout << a[j][i];
		}

		for (int i = 0; i < W; i++){
			if (a[j][i] == '#' || a[j][i] == '.'){
				cout << endl;
				break;
			}
		}

		
	}

	return 0;
}

Measured memory_bytes: 256
S=input()
Ans="Yes"
even=[i for i in range(len(S)) if i % 2 == 0 ]

for j in even:
    if S[j]=="L":
        Ans="No"
    else:
        pass

odd=[i for i in range(len(S)) if i % 2 ==1 ]

for j in odd:
    if S[j]=="R":
        Ans="No"
    else:
        pass

print(Ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> hs(n);
  vector<int> cnts(n, 0);
  rep(i, n) cin >> hs[i];
  cnts[n - 1] = 0;
  int ans = 0;
  for (int i = n - 2; 0 <= i; i--) {
    if (hs[i + 1] <= hs[i]) {
      cnts[i] += cnts[i + 1] + 1;
      ans = max(cnts[i], ans);
    }
  }
  cout << ans << endl;
  return 0;
}


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

int a[100][100];

int main() {
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  #endif
  int n, d, ans = 0;
  cin >> n >> d;
  for (int i = 0; i < n; ++i) for (int j = 0; j < d; ++j) cin >> a[i][j];
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int l = 0, r = 4000;
      int sqrdist = 0;
      for (int k = 0; k < d; ++k) sqrdist += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
      while (r - l > 1) {
        int m = (l + r) / 2;
        if (m * m > sqrdist) r = m;
        else l = m;
      }
      if (l * l == sqrdist) ++ans;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
if (x in a and y in a) or (x in b and y in b) or (x == 2 and y == 2):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
// 
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
  	uint64_t n,k;
	cin>>n>>k;
  	if(n>k) {
      cout<<llabs(n%k - k)% k;
    }
  else{
    if(n>k/2){
        auto x = n-k;
        x = llabs(x);
    	cout<<x%(k);
    }
    else{
      cout<<n;
    }
  }
  	
}

Measured memory_bytes: 256
import sys


def solve(inp):
    N = int(inp.readline().strip())
    A = list(map(int, inp.readline().strip().split(' ')))

    r = [0 for i in range(N)]
    for i in range(N):
        r[A[i] - 1] = i + 1

    return " ".join(map(str, r))


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


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

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  for(int i = 0; i < W + 2; i++) cout << "#"; 
  cout << endl;
  for(int i = 0; i < H; i++){ 
    cin >> vec.at(i);
    cout << "#" << vec.at(i) << "#" << endl;
  }
  for(int i = 0; i < W + 2; i++) cout << "#"; 
  cout << endl;
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,M;
  cin>>N>>M;
  
vector<pair<ll,ll>>C(N);
  priority_queue<ll>que;
  
  
  rep(i,N){
cin>>C[i].first>>C[i].second;
  }
  
  sort(all(C));
  
  ll ans=0;
   ll x=0;
  for(ll i=M-1;i>=0;i--){
 
   
  
          while(x<N&&C[x].first+i<=M){
que.push(C[x].second);
      x++;
          }
    if(!que.empty()){//que配列が空ではない時
      ans+=que.top();//一番上を加える
      que.pop();////一番上を消す
    }
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 2936
#include <stdio.h>
#include <string.h>

int main(void) 
{
  int n,i,len,k;
  scanf("%d",&k);
  char s[101];
  scanf("%s",s);
  len=strlen(s);
  if(len<=k)
  {
    printf("%s",s);
  }
  else
  {
    for(i=0;i<k;i++)
    {
      printf("%c",s[i]);
    }
    {
      printf("...");
    }
  }

  return 0;
}

Measured memory_bytes: 1688
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
void waru(vector<int>& v, int k, int p, vector<int>& ret){
    if(v.size()==1) return;
    int a=v.back();
    ret.push_back(a);
    v.pop_back();
    v.back()=(v.back()+a*k)%p;
    waru(v, k, p, ret);
}
ll powmod(ll a, ll k, ll m){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=m;
        }
        ap=ap*ap;
        ap%=m;
        k>>=1;
    }
    return ans;
}
ll inv(ll a, ll m){
	return powmod(a, m-2, m);
}
int main()
{
    int p; cin>>p;
    vector<int> v;
    for(int i=0; i<p; i++){
        int a; cin>>a;
        if(a==1) v.push_back(i);
    }
    if(v.empty()){
        cout<<0;
        for(int i=0; i<p-1; i++) cout<<" "<<0;
        cout<<endl;
        return 0;
    }else if(v.size()==p){
        cout<<1;
        for(int i=0; i<p-1; i++) cout<<" "<<0;
        cout<<endl;
        return 0;
    }
    int ans[3010]={};
    for(auto k:v){
        vector<int> w(p+1);
        w[p]=1;
        w[1]=p-1;
        vector<int> ret;
        waru(w, k, p, ret);
        int c=0, pp=1;
        for(int i=0; i<p; i++){
            (c+=ret[p-1-i]*pp)%=p;
            pp=pp*k%p;
        }
        c=inv(c, p);
        for(int i=0; i<p; i++) (ans[i]+=ret[p-1-i]*c)%=p;
    }
    for(int i=0; i<p; i++){
        cout<<ans[i];
        if(i<p-1) cout<<" ";
    }
    cout<<endl;
    return 0;
}

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

long long ar[100060];

int main()
{

    int n,j,i,cnt=0;
    long long area=1;

    scanf("%d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%lld",&ar[i]);
    }

    sort(ar,ar+n);

    j=n-1;

    while(cnt<2 && j>0)
    {
        if(ar[j]==ar[j-1])
        {
            cnt++;
            area*=ar[j];
            j-=2;
        }

        else j--;
    }

    if(cnt<2)
    {
        printf("0");
    }

    else(printf("%lld",area));

    return 0;

}


Measured memory_bytes: 1024
def perfect_square(a, b)
  sum = a.zip(b).inject(0){|r,(x,y)| r + (x-y)**2}

  (sum**0.5).round**2 == sum
end

n, d = gets.split.map(&:to_i)
a = n.times.map{ gets.split.map(&:to_i) }

cnt = 0
n.times do |i|
  (i+1).upto(n-1) do |j|
    if perfect_square(a[i], a[j])
      cnt += 1 
    end
  end
end

puts cnt


Measured memory_bytes: 1916
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
    
int main(){
    int N, M; cin >> N >> M;
    vp sides;
    for (int i = 1; i <= M; i++) {
        int a, b; cin >> a >> b;
        sides.push_back(P(a, b));
    }
    
    ll ret = 0;
    for (int i = 0; i < sides.size(); i++) {
        vb arrived(N + 1, false); arrived[0] = true;
        vp sides_c(sides.size());
        copy(sides.begin(), sides.end(), sides_c.begin());
        sides_c.erase(sides_c.begin() + i);
        queue<int> q;
        q.push(sides_c[0].first);
        while(!q.empty()){
            int cur = q.front(); q.pop();
            arrived[cur] = true;
            vp next;
            copy_if(sides_c.begin(), sides_c.end(), back_inserter(next), [=](P p){return p.first == cur || p.second == cur;});
            for(int j = 0; j < next.size(); j++){
                if(!arrived[next[j].second]){
                    q.push(next[j].second);
                }
                if(!arrived[next[j].first]){
                    q.push(next[j].first);
                }
            }
        }
        ll count = count_if(arrived.begin(), arrived.end(), [=](bool ok){return !ok;});
        if(count > 0) ret++;
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 256
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
    int n,wt; cin>>n>>wt;
    vi w(n), v(n);
    rep(i,0,n) cin>>w[i]>>v[i];
    vector<vll> dp(n+1,vll(wt+1,0));
    rep(i,1,n+1)
    {
        rep(j,1,wt+1)
        {
            if(j>=w[i-1])
            {
                dp[i][j] = max(dp[i-1][j-w[i-1]] + v[i-1], dp[i-1][j]);
            }
            else dp[i][j] = dp[i-1][j];
        }
    }
    cout<<dp[n][wt];
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1; //cin>>t;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <algorithm>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include<deque>

#define INF 1e9
#define MOD 1000000007
#define ll long long
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef unsigned long long ull;
typedef pair<ll, int> pr;

vector<int> to[111111],from[111111];
bool used[111111];
int takasa[111111];
deque<int>tpsort;
void dfs(int i){
    if(used[i]){
        return;
    }
    used[i]=true;
    for(auto& itr:to[i]){
        dfs(itr);
    }
    tpsort.push_front(i);
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    int nm=n+m-1;
    int a,b;
    for(int i=0;i<nm;i++){
        cin>>a>>b;
        a--;
        b--;
        to[a].push_back(b);
        from[b].push_back(a);
    }
    for(int i=0;i<n;i++){
        dfs(i);
    }
    int t=0;
    for(auto& itr:tpsort){
        takasa[itr]=t;
        t++;
    }
    // for(int i=0;i<n;i++){
    //     cout<<takasa[i]<<" ";
    // }
//    cout<<endl;
    for(int i=0;i<n;i++){
        if(from[i].empty()){
            cout<<0<<endl;
    //        cout<<"emp"<<endl;
            continue;
        }
        int ans=from[i][0];
        for(int j=1;j<from[i].size();j++){
            if(takasa[from[i][j]]>takasa[ans]){
                ans=from[i][j];
            }
        }
        cout<<ans+1<<endl;
    }

    return 0;
}

Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int N, M;
  cin >> N >> M;
  int homework = 0;
  for (int i = 0;i < M; i++) {
    int tmp;
    cin >> tmp;
    homework += tmp;
  }
  if (homework > N) cout << -1 << endl;
  else cout << N - homework << endl;
}


Measured memory_bytes: 3596