akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int N = 2*1e3+10;
const int inf = 0x3f3f3f3f;
int d[N][N];
int v[N];
int n, a, b;
int main(){
    cin >> n >> a >> b;
    for(int i=1;i<=n;++i){
        for(int j=i+1;j<=n;++j){
            d[j][i] = d[i][j] = j-i;
        }
    }
    d[a][b] = 1;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            d[i][j] = min(d[i][j],d[i][a]+d[j][b]+1);
            d[i][j] = min(d[i][j],d[i][b]+d[j][a]+1);
        }
    }
    for(int i=1;i<=n;++i){
        for(int j=i+1;j<=n;++j){
            v[d[i][j]]++;
            // cerr << d[i][j] << ' ';
        }
        // cerr << '\n';
    }
    for(int i=1;i<n;++i){
        cout << v[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 16000
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 2018-12-22 21:05:32
**/

#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

vector<pair<int64, int64>> prime_fact(int64 n){
    vector<pair<int64, int64>> result;
    for (int64 i = 2; i * i <= n; ++i){
        if (n % i != 0) continue;
        int64 cnt = 0;
        while (n % i == 0){
            n /= i; ++cnt;
        }
        result.emplace_back(i, cnt);
    }
    if (n != 1) result.emplace_back(n, 1);
    return result;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(__null);
    
    int64 n, p; cin >> n >> p;

    vector<pair<int64, int64>> vv = prime_fact(p);

    int64 m = vv.size();

    int64 ans = 1;

    for (int64 i = 0; i < m; ++i){
        if (vv[i].se >= n){
            ans *= pow(vv[i].fi, vv[i].se / n);
        }
    }
    print(ans);
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))

def main():
    N,A,B=map(int,input().split())
    S=list(input())
    c=0
    cc=0
    for i in range(N):
        if S[i]=='a':
            c+=YesNo(c<A+B)
        elif S[i]=='b':
            tmp=YesNo(c<A+B and cc<B)
            c+=tmp
            cc+=tmp
        else:
            YesNo(0)

if __name__ == '__main__':
    main()

f3=lambda b: bool([print('Yes')] if b else print('No'))

Measured memory_bytes: 59768
f=lambda:map(int,input().split())
A,B,m=f()
a=list(f())
b=list(f())
ans=min(a)+min(b)
for _ in range(m):
    x,y,c=f()
    ans=min(ans,a[x-1]+b[y-1]-c)
print(ans)

Measured memory_bytes: 24820
from sys import stderr, setrecursionlimit
setrecursionlimit(2147483647)
def getint():
    return int(input())
def getints():
    return [int(i) for i in input().split()]
def getintlines(n=1):
    res = []
    for _ in range(n):
        res.append(getint())
    return res
def getintslines(n=1):
    res = []
    for _ in range(n):
        res.append(getints())
    return res
def debug(*args, **kwargs):
    print(*args, file=stderr, **kwargs)

n = getint()
a = getints()
snuke = sum(a[:-1])
arai = a[-1]
ans = abs(snuke-arai)
for i in range(2, n):
    debug(a[-i])
    snuke -= a[-i]
    arai += a[-i]
    ans = min(abs(snuke - arai), ans)
    
print(ans)


Measured memory_bytes: 23784
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}



const ll N=2e5+5;

ll b[N];


struct cmp{
bool operator()(ll i,ll j)const
{
return b[i]>b[j];
}
};



int main()
{ 

IOS;

ll n;cin>>n;

ll m;cin>>m;

vl a(n+1);

priority_queue<ll>q;

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

vl lim[m];

ll ans=0;


for(int i=1;i<=n;i++){
  ll temp=m-a[i];
  if(temp<0)continue;
  lim[temp].pb(i);
}



for(int x=m-1;x>=0;x--){
 for(auto d:lim[x]){
  q.push(b[d]);
 }
 if(q.empty())continue;
ll p=q.top();
ans+=p;
q.pop();
//s.erase(it);
}


cout<<ans;



//end_routine();

return 0;
 
 }

Measured memory_bytes: 10024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

int main(){
  ll n;
  cin >> n;
  ll ans = n + n*n + n*n*n;
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 3620
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define huge 1000000007
typedef long long int ll;
ll gcd(ll a, ll b);
ll bur(ll N, ll X);
bool IsPrime(int num);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll L = 0;
	ll P = 0;
	//ll T = 0;
	//ll M = 0;
	ll h[1000] = {};
	//ll b[100] = {};
	//ll c[100] = {};
	//ll d[100] = {};

	//ll v[3] = {};
	//ll *c, *s, *n;
	string S[50],T[50],U[52];
	ll count = 0;
	ll count2 = 0;
	float sum = 0;
	ll min = 1000000000000;
	ll max = 1;
	ll dist1 = 0;
	ll dist2 = 0;
	ll now = 0;
	int tmax = 0;
	int tmax2 = 0;
	//int flag = 0;
	char temp,head;
	//int is = 0;
	bool flag = false;
	
	//char p;

	ll all = 0;
	ll niku = 0;
	ll state = 2;
	bool down = true;
	

	//cin >> S;
	
	
	
	int g[13] = {0,0,2,0,1,0,1,0,0,1,0,1,0};
	cin >> A >> B;
	
	
	if(g[A] == g[B])
	cout << "Yes" << endl;
	else
		cout << "No" << endl;
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());
	
	//cout << c[2] - c[1] << endl;

	
	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/
	


	//cin >> N >> M;

	//vector<pair<int,int>> c(M);
	////vector<pair<int, int>> e(M);
	//vector<ll> d(M);

	//rep(i, 0, M) {
	//	cin >> c[i].first >> c[i].second;
	//	//e[i].first = c[i].first;
	//	//e[i].second = c[i].second;

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

	//

	//rep(i, 0, M) {

	//	
	//	
	//	rep(j, 0, M) {
	//		if (c[i].first == c[j].first && c[j].second < c[i].second) {
	//			d[i]++;
	//			//cout << j << endl;
	//		}
	//	}
	//	cout << std::setfill('0') << std::right << std::setw(6) << c[i].first;
	//	cout << std::setfill('0') << std::right << std::setw(6) << d[i]+1 << endl;
	//}

	return 0;

}

ll bur(ll N,ll X) {
	ll pan = 1;
	ll pat = 1;
	ll burg = 0;



	if (X > burg) {
		if (N == 0)
			return pat;


		burg += pan;
		burg += bur(N - 1, X);
		burg += pat;
		burg += bur(N - 1, X);
		burg += pan;


	}

	return burg;

}

ll gcd(ll a, ll b) {
	
	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	ll x = b;
	ll y = a;
	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return y/b*x;
}

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n,k;
int maxsum=0,sum=0,maxid;
char s[100005],ans[100005];
int main()
{
	scanf("%d%d",&n,&k);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++) s[2*n-i+1]=s[i];
	for(int i=1;i<=n;i++) ans[i]=s[i];
	for(int i=2;i<=n;i++)
	{
		bool flag=1;
		for(int j=i;j<=n+i-1;j++)
		{
			if(ans[j-i+1]==s[j]) continue;
			if(ans[j-i+1]<s[j]) flag=0;
			break;
		}
		if(flag) for(int j=i;j<=n+i-1;j++) ans[j-i+1]=s[j];
	}
	for(int i=1;i<=n;i++)
	{
		if(ans[i]==ans[1]) maxsum=i;
		else break;
	}
	if(k>=16||1ll*maxsum*(1<<(k-1))>=n) for(int i=1;i<=n;i++) printf("%c",ans[1]);
	else
	{
		long long len=(1ll<<(k-1))*maxsum;
		for(int i=1;i<=len;i++) printf("%c",ans[1]);
		for(int i=1;i<=n-len;i++) printf("%c",ans[i+maxsum]);
	}
}

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

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

  string s;
  cin >> s;
  int total = 0;
  for (auto i : s) {
    total += i - '0';
  }
  if (total % 9 == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 3704
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
int main() {
	string str;
	cin >> str;
	int x_cnt=0;
	REP(i, str.size()) {
		if (str[i] == 'x') {
			x_cnt++;
		}
	}
	if (x_cnt >= 8) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}

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

int main()
{
	// ?????°??£?¨?
	int a;
	int b;
	int c;

	// ??\???
	cin >> a >> b >> c;

	// ??????
	if (a < b && b < c)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
S = input()
l_list = ['A','C','T','G']
ans_list = str()
for i,l in enumerate(S):
  if l in l_list:
    ans_list += '1'
  else:
    ans_list += '0'
ans_list = ans_list.split('0')
print(max([len(i) for i in ans_list]))


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

int main(void) {
    int n, q, time, passed;
    string name;
    typedef pair<string, int> P;
    queue<P> que;

    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        cin >> name >> time;
        que.push(make_pair(name, time));
    }

    passed = 0;
    while (!que.empty()) {
        name = que.front().first;
        time = que.front().second;
        que.pop();

        if (time <= q) {
            passed += time;
            cout << name << ' ' << passed << endl;
        }
        else {
            passed += q;
            que.push(make_pair(name, time - q));
        }
    }

    return 0;
}

Measured memory_bytes: 4404
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	n=II()
	A=LI()

	now=0
	ans=0
	for i in A:
		if i<=now:
			ans+=now-i
		else:
			now=i
	print(ans)




if __name__ == "__main__":
	main()


Measured memory_bytes: 92828
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h + w == 0) break;
		int l = h*h + w*w;
		int Minl = 40000, mh = 200, mw = 200;
		rep(i, 1, 151) {
			rep(j, i + 1, 151) {
				if (i == h && j == w) continue;
				int tmp = i*i + j*j;
				if (tmp == l && i > h) {
					Minl = l;
					mh = i;
					mw = j;
					i = 151;
					break;
				}
				else if (tmp > l && tmp < Minl) {
					Minl = tmp;
					mh = i;
					mw = j;
				}
			}
		}
		cout << mh << " " << mw << endl;
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = INT_MAX;
bool mywish(const pii &a,const pii &b)
  {
    return a.first > b.first;
  }
int factorial(int n)
 {
  int ans = 1;
  loop(i,1,n+1)
    ans *= i;
  return ans;
 }
int findrank(vector<int> v)
 {
  int mn = 1,rank = 0;
  int n = v.size();
  set<int> s;
  loop(i,1,n+1)
    s.insert(i);
  loop(i,0,n)
   {
     if(v[i] != *s.begin())
       {
        int diff = 0;
        for(auto x : s)
           {
            if(x == v[i])
               break;
            else 
              diff++;
           }
        rank += diff*factorial(n-i-1);
        //cerr<<i<<" "<<diff<<" "<<(n-i-1)<<" "<<mn<<END;
       }
    s.erase(v[i]);
   }
  cerr<<END;
  return rank;
 }
void solve()
  {
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    int v1,v2;
    loop(i,0,n)
      cin>>a[i];
    loop(i,0,n)
      cin>>b[i];
    v1 = findrank(a);
    v2 = findrank(b);
    //cout<<v1<<" "<<v2<<" ";
    cout<<abs(v1-v2);
  } 
signed main()
 {
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

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

    if (a + b > n + 1) {
        puts("-1");
        return 0;
    }
    if (a * b < n) {
        puts("-1");
        return 0;
    }

    rep(i, a) {
        cout << n - a + 1 + i << " ";
    }
    li rest = n - a; // まだ配置するやつ
    li bb = b - 1; // あと何回小さいのが出ればいいか
    while (rest > bb) {
        if (rest - a <= bb - 1) {
            li num = rest - (bb - 1);
            rep(i, num) {
                cout << rest - num + 1 + i << " ";
            }
            rest -= num;
            bb--;
            break;
        }
        rep(i, a) {
            cout << rest - a + 1 + i << " ";
        }
        rest -= a;
        bb--;
    }
    rep(i, rest) {
        cout << rest - i << " ";
    }
    cout << endl;


    return 0;
}

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

int main() {
  vector<int> v(5);
  for (size_t i = 0; i < 5; i++) {
    cin >> v[i];
  }
  vector<int> w(5);
  for (size_t i = 0; i < 5; i++) {
    w[i] = 1 + (v[i]-1) / 10;
  }
  int k = 10;
  for (size_t i = 0; i < 5; i++) {
    if (v[i]%10 != 0 && v[i]%10<k) {
      k = v[i]%10;
    }
  }
  cout << (w[0] + w[1] + w[2] + w[3] + w[4] - 1)*10 + k << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int a,b,c,n1,n2;
   cin>>a;
   cin>>b;
   cin>>c;
   n1=a*b;
   n2=c;
   if(n1<=n2)
   {
       cout<<n1;
   }
   else
   {
       cout<<n2;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

ll dp[100010][2];

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N);
	ll M{0};
	for (ll i = 0; i < N; ++i)
	{
		cin >> A[i];
		if (A[i] < 0)
		{
			++M;
			A[i] *= -1;
		}
	}

	sort(A.begin(), A.end(), greater<ll>());
	ll sum = accumulate(A.begin(), A.end(), 0ll);

	if (M&1)
		std::cout << sum - 2*A.back() << std::endl;
	else
		std::cout << sum << std::endl;
}

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

using namespace std;

int N,M,R;
int r[8];
int dp[202][202];
const int INF = 1e9;
int main() {
  cin >> N >> M >> R;

  for(int i = 0; i < R; i++) cin >> r[i];
  for(int i = 0; i < N; i++) fill(dp[i],dp[i]+N,INF);

  for(int i = 0; i < M; i++) {
    int A,B,C;
    cin >> A >> B >> C;
  
    A--; B--;
    dp[A][B] = C;
    dp[B][A] = C;
  }

  for(int k = 0; k < N; k++) {
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {
	dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);
	//	cout << dp[i][j]<<endl;
      }
    }
  }

  int tmp = 1;
  for(int i = 1; i <= R; i++) {
    tmp *= i;
  }

  int ans = INF;
  for(int i = 0; i < tmp; i++) {
    int sum = 0;
    for(int j = 0; j < R-1; j++) {
      sum += dp[r[j]-1][r[j+1]-1];
    }
   
    ans = min(ans,sum);
    next_permutation(r,r+R);
  }

  cout << ans << endl;
}
      


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    int a[n+1];
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if((i&1)+(a[i]&1)==2)
            ans++;
    }
    cout<<ans;

} 
    


Measured memory_bytes: 3632
/* ex5_3 melo */
#include <stdio.h>
#include <string.h>//文字列関数を読み取れるようにする
#include <stdlib.h>
int main(void){
    int row_N,col_N,i,j;
    char arrayc[100][100];
    int row_TorF[100], col_TorF[100];
    scanf("%d %d",&row_N,&col_N);
    for(i=0;i<row_N;i++){
        for(j=0;j<col_N;j++){
            scanf(" %c",&arrayc[i][j]);
        }
    }
    for(i=0;i<row_N;i++){
        row_TorF[i]=0;
    }
    for(j=0;j<col_N;j++){
        col_TorF[j]=0;
    }
    for(i=0;i<row_N;i++){
        for(j=0;j<col_N;j++){
            if(arrayc[i][j]=='#'){
                row_TorF[i]=1;
                col_TorF[j]=1;
            }
        }
    }
    for(i=0;i<row_N;i++){
        for(j=0;j<col_N;j++){
            if(row_TorF[i]==1&&col_TorF[j]==1){
                printf("%c",arrayc[i][j]);
            }
        }
        if(row_TorF[i]==1){
                printf("\n");
        }
    }
    return 0;
}

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

int main(){
    int n;
    ll ans = 0;
    cin >> n;
    vector<ll> a(n+1);
    for(int i = 0; i < n + 1; i++) cin >> a[i];
    vector<ll> b(n);
    for(int i = 0; i < n; i++) cin >> b[i];

    for(int i = 0; i < n; i++){
        if(a[i] + a[i+1] <= b[i]){
            ans += a[i] + a[i+1];
            a[i+1] = 0;
        }
        else{
            ans += b[i];
            if(a[i] < b[i]) a[i+1] -= b[i] - a[i];
        }
    }

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

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define nnm(x, y) (((y) + (x) % (y)) % (y))
template<typename T> inline T gcd(T x, T y) { if(x < y) swap(x, y); T mod = x % y; if(mod == 0) return y; return gcd(y, mod); }
template<typename T> inline T lmc(T x, T y) { return x / gcd(x, y) * y; }

int main(int argc, char* argv[])
{
	ll K;
	scanf("%lld", &K);
	//ll tempK = K;
	ll h1 = 49;
	h1 += (K / 50);
	K %= 50;
	/*
	while (K >= 50) {
		h1++;
		K -= 50;
	}
	*/
	ll h2 = h1;
	h2 += 40 * (K / 11);
	h1 -= 11 * (K / 11);
	K %= 11;
	/*
	while (K >= 11) {
		h2 += 40;
		K -= 11;
		h1 -= 11;
	}
	*/
	ll h3 = h2;
	h3 += 50 * K;
	h1 -= K;
	h2 -= K;
	/*
	while (K >= 1) {
		h3 += 50;
		K--;
		h1--;
		h2--;
	}
	*/
	printf("50\n");
	for (int i = 0; i < 50; i++) {
		if (i < 39)
			printf("%lld ", h1);
		else if (i < 49)
			printf("%lld ", h2);
		else
			printf("%lld\n", h3);
	}

	/*
	ll a[50];
	for (int i = 0; i < 50; i++) {
		if (i < 39) a[i] = h1;
		else if (i < 49) a[i] = h2;
		else a[i] = h3;
	}
	for (int k = 0; k < tempK; k++) {
		int M = -1;
		int index;
		for (int i = 0; i < 50; i++) {
			if (M < a[i]) {
				M = a[i];
				index = i;
			}
		}
		for (int i = 0; i < 50; i++) {
			if (i == index) a[i] -= 50;
			else a[i]++;
		}
		if (k != tempK - 1) continue;
		printf("%d\n", k + 1);
		for (int i = 0; i < 50; i++) {
			printf("%lld ", a[i]);
		}
		printf("\n");
	}
	*/

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int i,s[131072] = {0},n,k,c = 0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&s[i]);
	}
	for(i=1;i<=n;i++){
		if(i<s[i]){
			k = s[i];
			if(s[k] == i) c++;
		}
	}
	printf("%d",c);
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

// http://drken1215.hatenablog.com/entry/2019/06/15/135300

int main(void) {

    int n,m;
    cin >> n >> m;
    // cout << "IO1:" << n <<"," << m << endl;

    int *k,*p;
    int **s;

    k = new int[m];
    p = new int[m];

    s = new int*[m];
    for(int i = 0; i < m; ++i) {
        s[i] = new int[m];
    }

    for(int o = 0; o < m; ++o) {
        cin >> k[o];
        // cout << "line:" << k[o] << ":" << " ";
        for (int i = 0; i < k[o]; ++i) { 
            cin >> s[o][i];
            // cout << s[o][i] << " ";
            // 0-base indexにする
            s[o][i] -= 1;
        }
        // cout << endl;
    }
    // cout << "IO2,3" << endl;

    // cout << "k[] = ";
    // for(int i = 0; i < m; ++i) {
        // cout << k[i] << " ";
    // }
    // cout << endl;

    for( int i = 0 ; i < m; ++i) {
        cin >> p[i];
        // cout << p[i] << " ";
    }
    // cout << "IO4" << endl;

    // solve
    // bit全探索
    ll res = 0;

    // switchのon/offをbitで表現．2^n通りの組み合わせを探索する
    for(int bit = 0; bit < (1<<n); ++bit) {
        // cout << "bit:" << bit << endl;
        // ある組み合わせがOKかどうか調べる
        bool turnon = true;

        // 電球の数だけループして，すべての電球が点灯するか調べる
        for(int i = 0; i < m; ++i) {

            int sumv = 0;

            for(int si = 0; si < k[i]; ++si) {
                // cout << "s[i][si]="<< s[i][si]<< endl;;
                // cout << "bit:v="<<bit << ","<< (1<<s[i][si]) << endl;;
                if(bit & (1<<s[i][si])){
                    ++sumv;
                }
            }

            // cout << "sumv:" << sumv << ", check:" << sumv%2 << ", p[x]=" << p[i] << endl;
            if (sumv%2 != p[i]) {
                turnon = false;
            }
        }

        if (turnon) {
            res++;
            // cout << "RES:" << res << endl;
        }

    }

    cout << res << endl;

    return 0;
}

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

const int N=200010, P=(int)1e9+7;
int n, m, A, B;
int f[N];
 
int pow(int x, int t){
	int ans = 1;
	for(; t; t>>=1, x=x*1ll*x%P) if(t&1) ans=ans*1ll*x%P;
	return ans;
}

int C(int n, int m){
	return pow(f[m]*1ll*f[n-m]%P, P-2) *1ll*f[n]%P;
}

int main(){
	scanf("%d%d%d%d", &n, &m, &A, &B);
	if(A==n || B==m){ puts("0"); return 0; }
	int t1 = n+m-2; 
	f[0] = 1; for(int i=1; i<=t1; ++i) f[i]=f[i-1]*1ll*i%P;
	int ans = C(n+m-2, m-1);
	for(int i=n-A+1, j=A; i<=n; ++i, --j){
		ans -= C(i+B-2, B-1)*1ll*C(j+m-B-2, m-B-1)%P;
		if(ans<0) ans+=P;
	}
	printf("%d\n", ans);
}


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

int main(){
  string S;
  cin >> S;
  int Ans=0;
  for(int i=0; i<4; i++){
    if(S.at(i)=='+'){
      Ans++;
    }
    else{
      Ans--;
    }
  }
  cout << Ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,v[55];
ll solve(ll l,ll r){
   	vector<ll> t;
   	for(int i=0;i<=l;i++)
      	t.push_back(v[i]);
   	for(int i=r;i<n;i++)
      	t.push_back(v[i]);
   	sort(t.begin(),t.end());
   	ll lim=k-t.size();          
   	if(lim<0)return 0;
   	ll sum=0;
   	for(int i=0;i<t.size();i++){
      	if(t[i]<0&&lim>0){ 
        	lim--;
      	}
	  	else
	    	sum+=t[i];
   }
   return sum;
}
int main(){
   	cin>>n>>k;
   	for(int i=0;i<n;i++)  cin>>v[i];
   	ll ans=0;
   	for(int i=-1;i<n;i++)
	    for(int j=i+1;j<=n;j++){
	        ans=max(ans,solve(i,j));
	    }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
ll gcd(ll a,ll b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

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

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
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;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}








const int AMAX = 100000;

void solve() {
    long long N, K;
    cin >> N >> K;
    vector<long long> cnt(AMAX + 1);
    for (int i = 0; i < N; i++)
    {
        int a, b;
        cin >> a >> b;
        cnt[a] += b;
    }

    for (int ans = 1; ans <= AMAX; ans++)
    {
        if (K <= cnt[ans])
        {
            cout << ans << endl;
            return;
        }
        K -= cnt[ans];
    }
}

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


Measured memory_bytes: 4064
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
int x;
vector<int>v;
int main(){
	cin>>N>>x;
	REP(i,N){
		int a;
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	int ans=0;
	REP(i,N){
		if(x>=v[i]){
			x-=v[i];
			ans++;
		}else{
			break;
		}
	}
	if(ans==N&&x!=0)ans--;
	cout<<ans<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int a,b,k;
    set<int>seq;
    cin >> a >> b >> k;
    for (int i = a; i < a + k; i++) {
        if (a <= i && i <= b) {
            cout << i << endl;
            seq.insert(i);
        }
    }
    for (int i = b - k + 1; i <= b; i++) {
        if (a <= i && i <= b) {
            if (!seq.count(i))cout << i << endl;
        }
    }

    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n;
	cin >> n;
	
	vector<vector<int>> a(2, vector<int>(n));
	rep(i, 2) {
		rep(j, n) {
			cin >> a[i][j];
		}
	}

	vector<vector<int>> dp(2, vector<int>(n, 0));
	dp[0][0] = a[0][0];
	rep(j, n) {
		rep(i, 2) {
			//上にあるときは下と比べる
			if (i == 0) {
				chmax(dp[i + 1][j], dp[i][j] + a[i + 1][j]);
			}
			//下にあるときは右と比べる
			if (j + 1 < n) {
				chmax(dp[i][j + 1], dp[i][j] + a[i][j + 1]);
			}
		}
	}

	out(dp[1][n - 1]);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define rep(i, init, n) for (int i = init; i < n; i++)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define gcd __gcd
# define M_PI 3.14159265358979323846
using namespace std;
const ll mod = 1e9 + 7;
const int N = 2e5 + 4;
const ll MOD = 998244353;
bool visited[N];
vector<int> edge[N];
vector<int> conc[N];
int c = 0, f = 1;

ll POW(ll base, ll exponent){
    ll result = 1;
    while (exponent > 0)
    {
        if (exponent % 2 == 1)
            result = (result * base) % MOD;
        exponent = exponent >> 1;
        base = (base * base) % MOD;
    }
    return result;
}

ll Inv(ll x){
    return POW(x, MOD - 2);
}

void DFS(int src){
    visited[src] = 1;
    conc[c].pb(src);
    for(auto i : edge[src]){
        if(!visited[i]) DFS(i);
    }
}

int main(){
    int n, k;
    cin>>n>>k;
    int cnt[n + 1], c = 0;
    memset(cnt, 0, sizeof(cnt));
    rep(i, 0, k){
        int d;
        cin>>d;
        rep(i, 0, d){
            int x;
            cin>>x;
            cnt[x]++;
        }
    }
    rep(i, 1, n + 1) if(!cnt[i]) c++;
    cout<<c;
    return 0;
}


Measured memory_bytes: 13020
def main():
    _ = int(input())
    A = [int(i) for i in input().split()]
    if 0 in A:
        print(0)
    else:
        s = 1
        for a in A:
            s *= a
            if 10**18 < s:
                s = -1
                break
        if 10 ** 18 < s:
            s = 1
        print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 87752
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, i, j, k;
    cin >> n;
    vi l(n);
    for (i=0;i<n;i++) cin >> l[i];
    
    ll cnt=0;
    sort(l.begin(), l.end(), greater<>());
    
    for (i=0;i<n-2;i++)
        for (j=i+1;j<n-1;j++)
            for (k=j+1;k<n;k++){
                if (l[i] < (l[j] + l[k])) cnt++;
                else break;
            }
    cout << cnt << endl;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] h = new int[n];

        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        boolean[] good = new boolean[n];
        Arrays.fill(good, true);

        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (h[a - 1] == h[b - 1]) {
                good[a - 1] = false;
                good[b - 1] = false;
            } else if (h[a - 1] < h[b - 1]) {
                good[a - 1] = false;
            } else {
                good[b - 1] = false;
            }
        }

        int ans = 0;

        for (boolean b : good) {
            if (b) {
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}


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

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

ab=ab[::-1]

cnt=0
for [a,b] in ab:
    if (a+cnt)%b!=0:
        cnt+=(b)-(a+cnt)%b
    #print(a,b,cnt)
print(cnt)    


Measured memory_bytes: 61144
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<ll> x(n), y(n), a, b;
    rep(i, n){
        cin >> x[i] >> y[i];
        a.push_back(x[i]-y[i]);
        b.push_back(x[i]+y[i]);
    }
    ll maa = *max_element(all(a));
    ll mab = *max_element(all(b));
    ll mia = *min_element(all(a));
    ll mib = *min_element(all(b));
    ll ans = 0;
    chmax(ans, maa-mia);
    chmax(ans, mab-mib);
    cout << ans << endl;
}

Measured memory_bytes: 9756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        final String SPACE = " ";

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();

        final int cntData = Integer.parseInt(br.readLine());

        int a;
        int b;
        int c;
        String data[] = new String[3];

        String lineString;
        for (int i = 0; i < cntData; i++) {
            lineString = br.readLine();

            data = lineString.split(SPACE);
            a = Integer.parseInt(data[0]);
            b = Integer.parseInt(data[1]);
            c = Integer.parseInt(data[2]);

            if (a * a + b * b == c * c) {
                sb.append("YES\r\n");
            } else if (a * a + c * c == b * b) {
                sb.append("YES\r\n");
            } else if (b * b + c * c == a * a) {
                sb.append("YES\r\n");
            } else {
                sb.append("NO\r\n");
            }
        }

        System.out.print(sb);

    }
}

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

long tr(int x) {
	return  1l*x * x * x; //long型にするため1l
}

int main() {
	int n, k;
	cin >> n >> k;

	if (k % 2 == 1) {
		cout << tr(n / k) << endl;
	}
	else {
		cout << tr(n / k) + tr((n + k / 2) / k) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	vector<ll>a(n);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	sort(a.begin(),a.end());
	ll ans=1,sign=1;
	int l=0,r=n-1;
	if(k%2){
        ans=a[r--];
        --k;
        if(ans<0) sign=-1;
	}
	while(k){
        ll x=a[l]*a[l+1],y=a[r]*a[r-1];
        if(x*sign>y*sign){
            ans=x%mod*ans%mod;
            l+=2;
        }else{
            ans=y%mod*ans%mod;
            r-=2;
        }
        k-=2;
	}
	printf("%lld",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 4868
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define MOD 1000000007
typedef long long ll;
using namespace std;
int main()
{
	ll N, M;
  	cin >> N >> M;
  	vector<ll> a(M), s(N + 1);
  	for (int i = 0; i < M; i++){
    	cin >> a[i];
      	s[a[i]] = -1;
    }
  	int ii = 0;
  	for (int i = 0; i < M - 1; i++){
    	if (a[i + 1] - a[i] == 1) {
        	cout << 0 << endl;
          	exit(0);
        }
    }
  	s[0] = 1;
  	if (s[1] != -1){
    	s[1] = 1;
    }
  	for (int i = 2; i <= N; i++){
    	if (s[i] != -1) {
        	if (s[i - 2] == -1) {
            	s[i] = s[i - 1];
            } else if (s[i - 1] == -1) {
            	s[i] = s[i - 2];
            } else {
            	s[i] = (s[i - 1] + s[i - 2]) % MOD;
            }
        }
    }
  	cout  << s[N] << endl;
}

Measured memory_bytes: 1792
#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>;

void Main()
{
  ll n,m,k; cin >> n >> m >> k;
  vector<ll> a(n), b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  vector<ll> suma(n), sumb(m);
  
  ll maxind_a = n;
  suma[0] = a[0];
  for (int i=1; i<n; i++) {
    suma[i] = suma[i-1] + a[i];
  }
  for (int i=1; i<n; i++) {
    if (suma[i] >= k) {maxind_a = i; break;}
  }
  ll maxind_b = m;
  sumb[0] = b[0];
  for (int i=1; i<m; i++) {
    sumb[i] = sumb[i-1] + b[i];
  }
  for (int i=1; i<m; i++) {
    if (sumb[i] >= k) {maxind_b = i; break;}
  }
  
  maxind_a = min(maxind_a, n-1);
  maxind_b = min(maxind_b, m-1);
  ll maxnum = 0;
  for(ll i = maxind_a; i >= 0; i--){
    vector<ll>::iterator position = lower_bound(sumb.begin(), sumb.end(), k-suma[i]);  // 3 を二分探索
    ll idx_lower = distance(sumb.begin(), position);
    if (idx_lower == m) maxnum = max(maxnum, i+1+m);
    else if (suma[i] + sumb[idx_lower] <= k) {
      maxnum = max(maxnum, i+idx_lower+2);
    } else {
      if (idx_lower != 0) maxnum = max(maxnum, i+idx_lower+1);
      else if (suma[i] <= k) maxnum = max(maxnum, i+1);
    }
  }
  for(ll i = maxind_b; i >= 0; i--){
    vector<ll>::iterator position = lower_bound(suma.begin(), suma.end(), k-sumb[i]);  // 3 を二分探索
    ll idx_lower = distance(suma.begin(), position);
    if (idx_lower == n) maxnum = max(maxnum, i+1+n);
    else if (sumb[i] + suma[idx_lower] <= k) {
      maxnum = max(maxnum, i+idx_lower+2);
    } else {
      if (idx_lower != 0) maxnum = max(maxnum, i+idx_lower+1);
      else if (sumb[i] <= k) maxnum = max(maxnum, i+1);
    }
  }
  cout << maxnum << endl;
}

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


Measured memory_bytes: 9524
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
int main(void){
 int n,m,x,y,a,b;
 vector<int> X;
 vector<int> Y;
 
 cin>>n>>m>>x>>y;
 for(int i=0; i<n; i++){
  cin>>a;
  X.push_back(a);
 }
 for(int i=0; i<m; i++){
  cin>>b;
  Y.push_back(b);
 }

 for(int i=x+1;i<=y; i++){
  int check=1;
  for(int j=0; j<n; j++){
   if(X[j]<i);
   else check=0;
  }
  for(int j=0; j<m; j++){
	
   if(Y[j]>=i);
   else check=0;
  }
  if(check){
	  std::cout<<"No War"<<std::endl;
	  return 0;
  }
 }

 std::cout<<"War"<<std::endl;
 return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,k;
    Scd2(N,k);
    int ans = 1;
    while(N/=k){
        ans++;
    }

    printf ("%d\n", ans );

    return 0;
}



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

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, m[N][N], d[N];

void bfs(int s){
  int i, j, u;

  queue<int> q;
  q.push(s);

  for(i = 0 ; i < n ; i++) d[i] = INFTY;

  d[s] = 0;

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

    for(j = 0 ; j < n ; j++){
      if(m[u][j] == 0) continue;
      if(d[j] != INFTY) continue;
      d[j] = d[u] + 1;
      q.push(j);
    }
  }
  for(i = 0 ; i < n ; i++){
    cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
  }
}


int main(){
  int i, j, u, k, v;

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

  for(i = 0 ; i < n ; i++){
    cin >> u >> k;
    u--;
    for(j = 0 ; j < k ; j++){
      cin >> v;
      v--;
      m[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}


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

int main(){
  string a, b;
  cin >> a >> b;
  if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
N,Y=map(int,input().split())
answer=-1,-1,-1
for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
            answer=x,y,z
            break
        # BREAK from inner loop
    else:
        # Finish inner loop without BREAK
        continue
    break
    #　BREAK from outer loop
print(*answer)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
long long a[200005];
int main(){ 
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	long long fr=a[1];
	long long sum=0;
	for(int i=2;i<=n;i++){
		if(a[i]<fr){
			sum+=fr-a[i];
			a[i]+=fr-a[i];
		}
		fr=a[i];
	}
	printf("%lld",sum);
return 0;
} 

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

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

Measured memory_bytes: 256