akhauriyash/Code-Regression huggingface dataset:
/*
	ID: sixathofpain
	TASK: friday
	LANG: C++   

*/


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 998244353;
const int N = int(3e5) + 999;
#define int long long int

void print0(int x=0){
	cerr<<x<<endl;
	cout<<0<<endl;
	exit(0);
}
map<int,int> mp;

int32_t main(){
    IOS;
		
	string s;
	cin>>s;
	cout<<s[0]<<s[1]<<s[2]<<endl;



    return 0;
}

Measured memory_bytes: 3656
N=int(input())
S=[]
T=[]
for i in range(N):
  temp=list(input().split())
  S.append(temp[0])
  T.append(int(temp[1]))
s=input()

ans=0
flag=False
for i in range(N):
  if flag:
    ans+=T[i]
  if s==S[i]:
    flag=True
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int bubbleSort(int A[],int N);

int main(){

  int i,A[100],N,count;
  scanf("%d",&N);
  for(i = 0 ; i < N ; i++)scanf("%d",&A[i]);
  count = bubbleSort(A,N);
  for(i = 0 ; i < N ; i++){
    if(i > 0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

int bubbleSort(int A[], int N){
  int count = 0,flag,j,s;
  flag = 1 ;
  while (flag)
    {
      flag = 0;
      for (j = 1 ; j < N ; j++)
        {
          if (A[j] < A[j-1])
            {
              s = A[j];
              A[j] = A[j-1];
              A[j-1] = s;
              flag = 1;
              count++;
	                  }
        }
    }
  return count;
}




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

int main()
{
    ll n;
    cin>>n;
    double a[n];
    for(ll i=0;i<n;i++) cin>>a[i];

    sort(a,a+n);

    double a1 = a[0];
    double a2;
    for(ll i=1;i<n;i++)
    {
        a2 = a[i];
        a1 = (a1+a2)/2;
    }
    printf("%.6f",a1);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#define MAX 100000
using namespace std;

int n,k;
int t[MAX];

int check(long long p){
    int i;
    int cnt=0;
    for(i=0;i<k;i++){
        long long s=0;
        while((s+t[cnt])<=p){
            s=s+t[cnt];
            cnt++;
            if(cnt==n)return n;
        }
    }
    return cnt;
}

long long min_p(){
    long long left=0;
    long long right=ceil(100000.0*10000.0/k);
    long long mid;
    while(right-left>1){
        mid=(left+right)/2;
        int v=check(mid);
        if(v>=n)right=mid;
        else left=mid;
    }
    return right;
}

int main()
{
    cin>>n>>k;
    int i;
    for(i=0;i<n;i++){
        cin>>t[i];
    }
    long long p=min_p();
    cout<<p<<endl;
}

//int main(){
//    int c=ceil(11.0/3);
//    int d=11/3;
//    int e=floor(11/3);
//    int f=round(11/3);
//    cout<<c<<" "<<d<<" "<<e<<" "<<f<<endl;
//}

Measured memory_bytes: 3512
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    long long r = 0, g = 0, b = 0; //R, B, Bの出現回数
    long long full = 0; //第1の条件を満たすような組み合わせの数
    for(long long i = 0; i < N; i++){
        if(S.at(i) == 'R'){
        	r++;
        }else if(S.at(i) == 'G'){
        	g++;
        }else{
        	b++;
        }
    }

    full = r * g * b;

    long long sub = 0; //第1の条件を満たして、克、第2の条件を満たさなかった場合の組み合わせの数
    for(long long i = 0; i < N; i++){
        for(long long j = i + 1; j < N; j++){
            if(S.at(i) == S.at(j)) continue;
            long long k = 2 * j - i;
            if(k >= N || S.at(k) == S.at(i) || S.at(k) == S.at(j)){
                continue;
            }

            sub++;
        }
    }

    cout << full - sub << endl;

    return 0;
}


Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMultipleOf9 solver = new BMultipleOf9();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMultipleOf9 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String n = in.next();
            int ans = 0;

            long keta = 0;
            for (int i = 0; i < n.length(); i++) {
                keta += n.charAt(i) - '0';
            }

            // 出力
            if (keta % 9 == 0) {
                out.println("Yes");
            } else {
                out.println("No");

            }

        }

    }
}



Measured memory_bytes: 40460
fun main(args :Array<String>) {
    val n = readInteger()
    val aArray = readLongList()
    val y1 = aArray.reduceIndexed { index, acc, a ->
        if (index % 2 == 0) acc + a else acc - a
    }

    val yArray = arrayListOf<Long>()
    yArray += y1
    for (i in 1 until n) {
        yArray += 2 * aArray[i - 1] - yArray[i - 1]
    }
    println(yArray.joinToString(" "))
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
ll n;
const ll N_MAX = 3000+10;
ld pr[N_MAX];
ld dp[N_MAX][N_MAX]; // dp[i][j] = (i番目のコインまでで表がj個である確率)


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

    cin >> n;
    REP(i,n) cin >> pr[i];

    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=n;j++){
            if(i==0 && j==0) dp[i][j] = 1;
            else if(i==0) dp[i][j] = 0;
            else{
                if(j==0) dp[i][j] = dp[i-1][j] * (1.0-pr[i-1]);
                else dp[i][j] = dp[i-1][j] * (1.0-pr[i-1]) + dp[i-1][j-1] * pr[i-1];
            }
        }
    }
    ld ans = 0;

    for(ll i=n/2+1;i<=n;i++){
        ans += dp[n][i];
    }
    cout << SP(12) << ans <<endl;


    
    return 0;
}



Measured memory_bytes: 144972
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

K = int(input())

lunlun = []
def dfs(i,before):
    if i == 11:
        return
    lunlun.append(before)
    back = before%10
    for j in range(-1,2):
        t = back + j
        if 0 <= t < 10:
            dfs(i + 1,before*10 + t)

for i in range(1,10):
    dfs(1,i)
lunlun.sort()
print(lunlun[K - 1])


Measured memory_bytes: 12296
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
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<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,q,N;
vl a,b,c;

bool f(ll m,ll x){;
	int L=a[N-2*m+1],R=a[N-m-1];
	return x-abs(x-a[N-m])<=L&&R<=a[N-m];
}

int main(){
	cin>>n>>q;
	N=3*n;
	a=vl(N,-inf);
	b=c=vl(N);
	for(int i=2*n;i<N;i++){
		cin>>a[i];
		b[i]=c[i]=a[i];
	}
	for(int i=2*n;i<N;i++) b[i]+=b[i-2];
	for(int i=N-2;i>=0;i--) c[i]+=c[i+1];
	for(int i=0;i<q;i++){
		ll x,l=0,r=n;
		cin>>x;
		while(r-l>1){
			int m=(l+r)/2;
			if(f(m,x)) l=m;
			else r=m;
		}
		cout<<b[N-2*l-1]+c[N-l]<<endl;
	}
}

Measured memory_bytes: 8704
#include <iostream>
#include <string>
#include <random>

using namespace std;

//サイコロクラス
class Dice
{
public:
	int face[6];	//各面の値を保持
	
public:

	Dice(int val[])
	{
		face[0] = val[0];
		face[1] = val[1];
		face[2] = val[2];
		face[3] = val[3];
		face[4] = val[4];
		face[5] = val[5];
	}

	//サイコロを転がす処理
	void ProcRoll(string s)
	{
		for (int i = 0; i < (int)s.size(); ++i)
		{
			switch (s[i])
			{
			case 'E':
				RollE();
				break;

			case 'W':
				RollW();
				break;

			case 'N':
				RollN();
				break;

			case 'S':
				RollS();
				break;


			}
		}
	}

	//上面と前面の数字を決めて
	void SetDice()
	{
		//


	}

	//E方向に転がした時の処理
	void RollE()
	{
		//値の入れ替えは図を参照
		int tmp = face[0];
		face[0] = face[3];
		face[3] = face[5];
		face[5] = face[2];
		face[2] = tmp;
	}

	//W方向に転がした時の処理
	void RollW()
	{
		//値の入れ替えは図を参照
		int tmp = face[0];
		face[0] = face[2];
		face[2] = face[5];
		face[5] = face[3];
		face[3] = tmp;
	}

	//N方向に転がした時の処理
	void RollN()
	{
		//値の入れ替えは図を参照
		int tmp = face[0];
		face[0] = face[1];
		face[1] = face[5];
		face[5] = face[4];
		face[4] = tmp;
	}

	//S方向に転がした時の処理
	void RollS()
	{
		//値の入れ替えは図を参照
		int tmp = face[0];
		face[0] = face[4];
		face[4] = face[5];
		face[5] = face[1];
		face[1] = tmp;
	}


};

//
int main()
{
	//
	int input[6];

	//
	string str = "";

	//サイコロの面の値を取得
	cin >> input[0] >> input[1] >> input[2] >> input[3] >> input[4] >> input[5];


	//サイコロクラスの宣言
	Dice dice(input);

	//質問数を格納する
	int qnum = 0;

	//質問の数を設定
	cin >> qnum;

	//問題数でループ
	for (int i = 0; i < qnum; ++i)
	{
		//乱数生成
		random_device rd;

		//
		int num[2];

		//上面と前面の値を入力
		cin >> num[0] >> num[1];

		//
		while (true)
		{
			//0～3の乱数を生成
			int r = rd() % 4;

			//
			switch(r)
			{
				//0の場合はE方向に
				case 0:
					dice.RollE();
					break;

				//1の場合はN方向に
				case 1:
					dice.RollN();
					break;

				//2の場合はS方向に
				case 2:
					dice.RollS();
					break;

				//3の場合はW方向に
				case 3:
					dice.RollW();
					break;

				defaule:
					break;

			}

			//重なった場合は3の面の数字を出力して終了
			if (
				dice.face[0] == num[0] &&
				dice.face[1] == num[1]
				)
			{
				cout << dice.face[2] << endl;

				break;
			}

		}			
		
	}

}


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

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

    int a, b, c, d;
    cin >> a >> b >>c >> d;

    int dx = c - a;
    int dy = d - b;

    int e = c - dy;
    int f = d + dx;

    int g = e - dx;
    int h = f - dy;

    cout << e << " " << f << " " << g << " " << h << endl;

}

Measured memory_bytes: 256
n=int(input())
s=input()

r_cnt=s.count("R")
g_cnt=s.count("G")
b_cnt=s.count("B")

ans=r_cnt*g_cnt*b_cnt

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n:
            break
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            ans-=1

print(ans)   

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

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 2e6+ 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 2e5 + 17;

int n, m, s, t;
vector< pair<int, ll> > g[maxn];
vector<int> g1[maxn];
ll ds[maxn], dt[maxn], dps[maxn], dpt[maxn];
bool used[maxn];

bool read() {
    if (scanf("%d %d %d %d", &n, &m, &s, &t) != 4)
        return false;

    --s, --t;

    forn (i, m) {
        int u, v, x;
        scanf("%d %d %d", &u, &v, &x);
        g[u - 1].push_back(make_pair(v - 1, x));
        g[v - 1].push_back(make_pair(u - 1, x));
    }

    return true;
}

void dijkstra(int v, ll* d) {
    fill(d, d + n, inf * inf);
    d[v] = 0;
    set< pair<ll, int> > Q;
    Q.insert(make_pair(d[v], v));

    for (; !Q.empty(); ) {
        v = Q.begin()->second;
        Q.erase(Q.begin());

        for (auto to : g[v])
            if (d[v] + to.second < d[to.first]) {
                Q.erase(make_pair(d[to.first], to.first));
                d[to.first] = d[v] + to.second;
                Q.insert(make_pair(d[to.first], to.first));
            }
    }
}

void dfs(int v, int s, ll* dp) {
    used[v] = true;

    if (v == s)
        dp[v] = 1;
    else
        dp[v] = 0;

    for (auto to : g1[v]) {
        if (!used[to])
            dfs(to, s, dp);

        dp[v] += dp[to];
        dp[v] %= inf;
    }
}

void solve() {
    dijkstra(s, ds);
    dijkstra(t, dt);

    for (int i = 0; i < n; ++i)
        for (auto to : g[i])
            if (ds[to.first] == ds[i] + to.second)
                g1[to.first].push_back(i);

    dfs(t, s, dps);

    forn (i, n)
        g1[i].clear();

    for (int i = 0; i < n; ++i)
        for (auto to : g[i])
            if (dt[to.first] == dt[i] + to.second)
                g1[to.first].push_back(i);

    fill(used, used + n, false);
    dfs(s, t, dpt);

    ll ans = dps[t] * dpt[s] % inf;

    for (int v = 0; v < n; ++v)
        for (auto to : g[v]) {
            int u = to.first;
            ll dd = to.second;

            if (ds[u] == ds[v] + dd && dt[v] == dt[u] + dd && ds[u] + dt[u] == ds[t] && dt[v] + ds[v] == ds[t]) {
                ll cnt = (dps[v] * dpt[u] % inf) * (dpt[u] * dps[v] % inf) % inf;

                if (abs(ds[v] - dt[u]) < dd)
                    ans = (inf + ans - cnt) % inf;
            }
        }

    for (int i = 0; i < n; ++i)
        if (ds[i] == dt[i] && ds[i] + dt[i] == ds[t])
            ans = (inf + ans - (dps[i] * dpt[i] % inf) * (dps[i] * dpt[i] % inf) % inf) % inf;

    printf("%lld\n", ans);
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}

Measured memory_bytes: 36352
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> P;
typedef pair<ll,P> PP;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

ll n;
ll b[100];
list<ll> B;

int main(){
    cin>>n;
    REP(n)cin>>b[i];
    REP(n)B.push_back(b[i]);
    B.reverse();
    vector<ll> ans;
    For(i,n){
        ll k=B.size();
        for(auto&& j : B)
        {
            dump(j);
        }
        
        for(auto itr=B.begin(); itr != B.end(); ++itr,--k){
            if(*itr==k){
                ans.push_back(k);
                B.erase(itr);
                break;
            }
        }
        
    }
    if(ans.size()!=n){
        cout<<-1<<endl;
        return 0;
    }
    for(auto itr=ans.rbegin();itr!=ans.rend();++itr){
        cout<<*itr<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;
using ll = long long;

queue<int> q;
vector<bool> visit;

typedef struct {
    vector<int> edge;
    int dis_u;
    int dis_v;
}node_t;
vector<node_t> node;

void bfs_u(vector<bool>& visit) {
    int x = q.front();
    q.pop();
    visit[x] = true;

    for (auto to : node[x].edge) {
        if (visit[to])continue;
        node[to].dis_u = node[x].dis_u + 1;
        q.push(to);
    }

    if (!q.empty())
        bfs_u(visit);
}

void bfs_v(vector<bool>& visit) {
    int x = q.front();
    q.pop();
    visit[x] = true;

    for (auto to : node[x].edge) {
        if (visit[to])continue;
        node[to].dis_v = node[x].dis_v + 1;
        q.push(to);
    }

    if (!q.empty())
        bfs_v(visit);
}

bool cmp(const node_t& a, const node_t& b)
{
    if (b.dis_v != a.dis_v)
        return b.dis_v < a.dis_v;
    else
        return a.dis_u < b.dis_u;
}

int main() {
    int N, u, v;
    cin >> N >> u >> v;


    node = vector<node_t>(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        node[a-1].edge.push_back(b-1);
        node[b-1].edge.push_back(a-1);
    }

    visit = vector<bool>(N);
    q.push(u-1);
    bfs_u(visit);
   
    visit = vector<bool>(N);
    q.push(v-1);
    bfs_v(visit);
    
    sort(node.begin(), node.end(), cmp);
   
    for (int i = 0; i < N; i++) {
        if (node[i].dis_u <= node[i].dis_v) {
            if (node[i].dis_v - node[i].dis_u < 2)
                cout << node[i].dis_u << endl;
            else
                cout << node[i].dis_v - 1<< endl;
            break;
        }
    }

}


Measured memory_bytes: 14464
#include <iostream>
#include <cmath>


using namespace std;

int main(){
    int N;
    int M;

    scanf("%d %d", &N, &M);
    int sub;
    int sum = 0;

    for (int i = 0; i < M; i++)
    {
        scanf("%d", &sub);
        sum += sub;
    }
    int date = N - sum;
    if (date < 0)
    {
        date = -1;
    }
    
    printf("%d\n", date);


    return 0;
}

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

int main(){
    int bul[5][4][11];
    for(int i=1;i<=4; i++){
        for(int j =1;j<=3;j++){
            for(int k=1;k<=10;k++){
                bul[i][j][k]=0;
            }
        }
    }
    
    int n;
    cin >> n;
    for(int l=0;l<n;l++){
        int b,f,r,v;
        cin >> b>> f >> r >> v;
        bul[b][f][r] +=v;
    }
    
    for(int b =1;b<=4;b++){
        if(b>1){
            cout << "####################\n";
        }
        for(int r=1;r<=3;r++){
            for(int f=1;f<=10;f++){
                cout <<" " <<bul[b][r][f];
            }
            cout <<endl;
        }
    }
            
  return 0;          
}
    



Measured memory_bytes: 3108
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

int a[100005];
int dp[100005];
int n,k;
int solve(int idx){
    if(idx==(n-1))
        return 0;
    if(idx>=n)
        return INF;
    int &ret = dp[idx];
    if(~ret)
        return ret;
    ret = INF;
    for(int i=1;i<=k;++i){    
        ret=min(ret,solve(idx+i)+abs(a[idx+i]-a[idx]));
    }
    return ret;
}



int main(){

    cin>>n>>k;
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    memset(dp,-1,sizeof dp);
    cout<<solve(0)<<endl;
    return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i=1; ; i++){
            int x = sc.nextInt();
            if(x == 0) break;
            else System.out.printf("Case %d: %d\n",i,x);
            }
        }
    }



Measured memory_bytes: 68172
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [INT() for _ in range(N)]


seq = A[::-1]
LIS = [seq[0]]
for i in range(1, len(seq)):
	if seq[i] >= LIS[-1]:
		LIS.append(seq[i])
	else:
		LIS[bisect.bisect(LIS, seq[i])] = seq[i]

print(len(LIS))


Measured memory_bytes: 10660
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    scanf("%d", &n);
    ll d[105];
    for(int i = 0; i < n; ++i)
        cin>>d[i];
    ll ans = 0;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            if(j <= i)
                continue;
            ans += d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public const int MD = 1000000007;
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s1 = Console.ReadLine().Trim();
        var s2 = Console.ReadLine().Trim();
        var p = 0; var prev = false; long ret;
        if (s1.Substring(p, 1) == s2.Substring(p, 1)) { p++; ret = 3; prev = true; }
        else { p += 2; ret = 6; }
        while (p < s1.Length)
        {
            if (s1.Substring(p, 1) == s2.Substring(p, 1))
            {
                if (prev) { ret *= 2; ret %= MD; }
                p++; prev = true;
            }
            else
            {
                if (prev) { ret *= 2; ret %= MD; }
                else { ret *= 3; ret %= MD; }
                p += 2; prev = false;
            }
        }
        Console.WriteLine(ret);
    }
}


Measured memory_bytes: 13140
n = int(input())
A = list(map(int, input().split()))
A = sorted(A)
change_point = 0 
a = 0

if A[0] >=0:
    print(sum(A)-A[0]*2)
    a = A[0]
    for i in range(n-2):
        print(a,A[i+1])
        a = a - A[i+1]
    print(A[-1],a)
           
elif A[-1] <=0:
    print(-sum(A)+2*A[-1])
    a = A[-1]
    for i in range(n-1):
        print(a,A[i])
        a = a - A[i]
else:
    for i in range(n):
        if A[i]>= 0:
            change_point = i
            break   
    print(sum(A)-2*sum(A[0:i]))
    a = A[0]
    for i in range(n - change_point-1):
        print(a,A[-(i+1)])
        a = a - A[-(i+1)]
    print(A[change_point],a)
    a = A[change_point]-a
    for i in range(change_point-1):
        print(a,A[i+1]) 
        a = a - A[i+1]

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

std::string S;

const std::string ATGC = "ATGC";

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

    std::cin >> S;

    int L = S.size();

    int mx = 0;

    for(int i=0;i<L;++i){
        for(int j=1;i+j<=L;++j){
            bool ok = true;

            for(int k=0;k<j;++k){
                if(std::count(ATGC.begin(), ATGC.end(), S[i+k]) == 0){
                    ok = false;
                    break;
                }
            }

            if(ok){
                mx = std::max(mx, j);
            }
        }
    }

    std::cout << mx << std::endl;
}


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

int main() {
  int N, x;
  scanf("%d%d", &N, &x);

  vector<int> a(N, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a.at(i));
  }

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (x - a.at(i) >= 0) {
      x -= a.at(i);
      ans++;
    } else {
      break;
    }
  }

  if (ans == N && x > 0) {
    // N人にお菓子を配り、それでも余っている場合は誰か一人に余りを渡す
    ans--;
  }

  printf("%d", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    ull x;
    cin >> x;

    ull ans = 0;
    ull y = 100;
    while(y < x){
        y = (y/100)*101 + ((y%100)*101/100);
        ans++;
    }

    cout << ans << endl;
}



Measured memory_bytes: 3604
def func(num):
    cnt=0
    while(num>0):
        num=int(num/10)
        cnt+=1
    return cnt

N=int(input())
ans=100
for i in range(1,int(N**(1/2)+1)):
    tmp=100
    if(N%i==0):
        tmp=max(func(i),func(N/i))
    ans=min(ans,tmp)
print(ans)

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

#define pi acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define	inf (ll)1e15
#define mod 1000000007
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

using namespace __gnu_pbds;
using namespace std;

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;

const int S=100100;

ll fac[S+5];
ll invFac[S+5];
 
ll bigMod(ll b,ll p)
{
    ll ret=1;
    while(p)
    {
        if(p&1)ret=(ret*b)%mod;
        b=(b*b)%mod;
        p>>=1;
    }
    return ret;
}
 
void calFac()
{
    fac[0]=1;
    for(ll i=1;i<=S;i++)fac[i]=(fac[i-1]*i)%mod;
 
    invFac[S]=bigMod(fac[S],mod-2);
 
    for(ll i=S-1;i>=0;i--)invFac[i]=((i+1)*invFac[i+1])%mod;
 
}
 
ll nCr(ll n,ll r)
{
    return (((fac[n]*invFac[r])%mod)*invFac[n-r])%mod;
}


int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //#endif
    calFac();
    int n;
    while(~sf("%d",&n))
    {
    	n++;
    	int ara[n+5];
    	for(int i=1;i<=n;i++)sf("%d",&ara[i]);

    	int gotIt[n+5];
    	mem(gotIt,-1);

    	int left,right;
    	for(int i=1;i<=n;i++)
    	{
    		if(gotIt[ara[i]]!=-1)
    		{
    			left=gotIt[ara[i]]-1;
    			right=n-i;
    			break;
    		}
    		gotIt[ara[i]]=i;
    	}

    	for(int k=1;k<=n;k++)
    	{
    		ll tot=nCr(n,k);

    		ll sub=0;
    		if(left+right>=k-1)sub=nCr(left+right,k-1);

    		ll ans=(tot-sub+mod)%mod;
    		pf("%lld\n",ans);
    	}
    }
    return 0;
}
 





































Measured memory_bytes: 6108
N = int(input())
A = list(map(int, input().split()))

ans = []
sum = 0

for i in range(N):
    if i == 0:
        sum += abs(A[0])
        continue
    sum += abs(A[i-1]-A[i])

sum += abs(A[N - 1])

for i in range(N):
    if i == 0:
        v = abs(A[0])+abs(A[0]-A[1]) - abs(A[1])
        print(sum - v)
        continue
    if i == N - 1:
        v = abs(A[i-1]-A[i])+abs(A[i]) - abs(A[i - 1])
        print(sum - v)
        continue
    v = abs(A[i-1]-A[i]) + abs(A[i]-A[i+1]) - abs(A[i-1]-A[i+1])
    print(sum - v)

Measured memory_bytes: 14172
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

class mycmp{
public:
	bool operator()(const P p1,const P p2){
		if(p1.first != p2.first) return p1.first > p2.first;
		else return p1.second < p2.second;
	}
};

int main(){
	int n,m;
	while(~scanf("%d %d",&n,&m)){
		if(n==m && m==0) break;
		vector<P> freq(m);
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				int isok;
				scanf("%d",&isok);
				freq[j].first += isok;
				freq[j].second = j+1;
			}
		}

		sort(freq.begin(),freq.end(),mycmp());

		for(int i=0;i<m;i++){
			printf("%s%d",i==0 ? "" : " ", freq[i].second);
		}
		printf("\n");
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    int n;
    cin >> n;
    vector<P> ab(n);
    for (P& p : ab) cin >> p.first >> p.second;
    sort(ab.begin(), ab.end());
    double am = (ab[n / 2].first + (n % 2 ? 0 : ab[n / 2 - 1].first)) /
                (n % 2 ? 1.0 : 2.0);
    sort(ab.begin(), ab.end(), [](P a, P b) { return a.second < b.second; });
    double bm = (ab[n / 2].second + (n % 2 ? 0 : ab[n / 2 - 1].second)) /
                (n % 2 ? 1.0 : 2.0);
    double res = (bm - am) * (n % 2 ? 1 : 2) + 1;
    int ri     = res;
    if (abs(res - ri) < 1e-2)
        cout << ri;
    else
        cout << ri + 1;
    return 0;
}


Measured memory_bytes: 4816
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
int Arr[100005];
void seive(){
		Arr[0]=Arr[1]=1;
		for(int i=2;i<100005;++i){
			if(Arr[i]==0)
			for(int j=2*i;j<100005;j+=i)
			Arr[j]=1;
		}
}
// -----------------------------------------------------------------------


// -----------------------------------------------------------------------



void q1(){
	int a;
	cin>>a;
	cout<<48-a;
	
}
// -----------------------------------------------------------------------


void q2(){
	int a,b;
	cin>>a>>b;
	string s;cin>>s;
	if(s[a]!='-'){
		cout<<"No\n";
		return ;
	}
	for(int i=0;i<=a+b;++i){
		if(i==a)
		continue;
		if(!(s[i]>='0' && s[i]<='9')){
			cout<<"No\n";
			return ;
		}
	}
	cout<<"Yes\n";
}

// -----------------------------------------------------------------------

void q3(){
	int n;
	cin>>n;
	int c[n-1],s[n-1],f[n-1];
	for(int i=0;i<n-1;++i)
	cin>>c[i]>>s[i]>>f[i];
	int res[n];
	res[n-1]=0;
	for(int i=n-2;i>=0;--i){
		int t=s[i]+c[i];
		for(int j=i+1;j<n-1;++j){
			if(t<=s[j]){
				t=s[j];
				t+=c[j];
			}else{
				int next = (t+f[j]-1)/f[j];
				next*=f[j];
				t=next+c[j];
			}
		}
		res[i]=t;
	}
	for(int i=0;i<n;++i)
	cout<<res[i]<<endl;
}


// -----------------------------------------------------------------------

void q4(){
	seive();
	int ans[100005];
	ans[0]=ans[1]=ans[2]=0;
	for(int i=3;i<100005;++i){
		if(Arr[i]==0){
			int n=(i+1)/2;
			if(Arr[n]==0)
			ans[i]=1;
		}
	}
	for(int i=1;i<100005;++i)
	ans[i]+=ans[i-1];
	int q;cin>>q;
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<ans[r]-ans[l-1]<<endl;
	}
}

// -----------------------------------------------------------------------


int32_t main()
{
	mod=1e+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	q1();
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  while(1){
    int n, m, results[100], i ,j;
    memset(results, 0, sizeof(results));
    scanf("%d%d", &n, &m);
    if(n == 0 && m == 0)return 0;
    for(i = 0;i < n;i++){
      for(j = 0;j < m;j++){
	int k;
	scanf("%d", &k);
	results[j] += k;
      }
    }
    int first = 0;
    for(i = n;i >= 0;i--){
      for(j = 0;j < m;j++){
	if(results[j] == i){
	  if(first == 1)putchar(' ');
	  printf("%d",j + 1);
	  first = 1;
	}
      }
    }
    puts("");
  }
}

Measured memory_bytes: 616
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int A, B;

    cin >> A >> B;

    cout << A*B << endl;

    return 0;
    
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> num(n);
  for(int i = 0;i < n;i++)cin >> num[i];
  ll now = 0;
  ll wa = 0;
  now = 1;
  ll count = 0;
  ll res = 0;
  res = INT_MAX;
  for(int i = 0;i < n;i++){
    wa += num[i];
    if(now == 1 && wa < now)count += now - wa,wa = 1;
    else if(now == -1 && wa > now)count += wa - now,wa = -1;
    now *= -1;
      //cout << i << " "<< wa << " " << count<< endl;
  }
  res = count;
  wa = 0;
  now = -1;
  count = 0;
  for(int i = 0;i < n;i++){
    wa += num[i];
    if(now == 1 && wa < now)count += now - wa,wa = 1;
    else if(now == -1 && wa > now)count += wa - now,wa = -1;
    now *= -1;
  }
  res = min(count,res);
  cout << res << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
    int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    string week[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
 
    for(;;){
        int month, day;
        cin >> month >> day;
        if(month == 0) return 0;
        int num = 0;
        for(int i=0; i<month-1; ++i)
            num += days[i];
        num += day; 
        cout << week[(num+2)%7] << endl;
    }
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int A[1100000];
signed main() {
    cin >> N;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] -= i;
    }
    sort(A, A + N);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += abs(A[i] - A[N / 2]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import sys

x = input()

if len(x) != 3 :
    sys.exit()

k=0

for k in range(2):
    if x[k] != "R":
        if x[k] != "S":
            print("無効な値です")
            sys.exit()
    k=k+1


i=0
if x[0]=="R":
    i = i+1
    if x[1]=="R":
        i = i+1
        if x[2]=="R":
            i = i+1
elif x[1]=="R":
    i = i+1
    if x[2]=="R":
        i = i+1
elif x[2] =="R":
    i = i+1    

print(i)

Measured memory_bytes: 9140
N = gets.to_i
arr = gets.split.map(&:to_i).sort{|x,y|y <=> x}
alice = 0; bob = 0
arr.each_index do |i|
  if i.even?
    alice += arr[i]
  elsif i.odd?
    bob += arr[i]
  end
end
puts alice - bob


Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

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

    long long ans;
    double cnt, prb = 0.0;
    for (int i = 1; i <= n; i++) {
        ans = i;
        cnt = 0.0;
        while (ans < k) {
            ans *= 2;
            cnt += 1.0;
        }
        if (cnt == 0) {
            prb += 1 / (double)n;
        }
        else {
            prb += (1 / (double)n) * pow(1 / 2.0, cnt);
        }

        //cout << fixed << setprecision(9) << prb << endl;
    }

    cout << fixed << setprecision(15) << prb << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main() {
  int n; cin >> n;
  set<int> st;
  for (int i = 0; i < n; i++) {
    int d; cin >> d;
    st.insert(d);
  }
  cout << st.size() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> pic;

    rep(i, H) {
        string S;
        cin >> S;
        pic.push_back(S);
        pic.push_back(S);
    }

    for(auto i : pic) {
        cout << i << endl;
    }
}

Measured memory_bytes: 256
#include <string>
#include <stdio.h>
#include <iostream>
using namespace std;
string s;
long long ans=0;
void solve(int i,string t,long long sum,long long nw) {
    if (i==(int)s.size()) {
        if (nw) sum+=nw;
        // printf("%s = %lld\n",t.c_str(),sum);
        ans+=sum;
        return;
    }
    solve(i+1,t+s[i],sum,nw*10+s[i]-'0');
    if (i) solve(i+1,t+'+'+s[i],sum+nw,s[i]-'0');
}
int main() {
    cin>>s;
    solve(0,"",0,0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int N,W,i,j;
  scanf("%d%d",&N,&W);
  int v[N],w[N];
  for(i=0;i<N;i++){
    scanf("%d%d",&v[i],&w[i]);
  }
  int Nap[W+1][N];
  for(i=0;i<=W;i++){
    Nap[i][0]=v[0]*(i/w[0]);
    //printf("%d ",Nap[i][0]);
  }
  for(j=1;j<N;j++){
    for(i=0;i<=W;i++){
      int x=0,y=0,z=0,max;
      x=Nap[i][j-1];
      if(i-w[j]>=0) y=Nap[i-w[j]][j-1]+v[j];
      if(i-w[j]>=0) z=Nap[i-w[j]][j]+v[j];
      if(x>y) max=x;
      else max=y;
      if(max<z) max=z;
      Nap[i][j]=max;
    }
  }
 /*for(j=0;j<N;j++){
    for(i=0;i<=W;i++){
      printf("%d ",Nap[i][j]);
    }
    printf("\n");
  }*/
   printf("%d\n",Nap[W][N-1]);
  return 0;
}



Measured memory_bytes: 5752
#include <stdio.h>

int main( void ) {
	int i, n, a, b, c;

	scanf( "%d", &n );
	while ( n-- ) {
		scanf( "%d %d %d", &a, &b, &c );

		if ( a * a + b * b == c * c || b * b + c * c == a * a || c * c + a * a == b * b )
			puts( "YES" );
		else
			puts( "NO" );
	}

	return 0;
}

Measured memory_bytes: 576
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn calc(n: usize, bits: usize, costs: &Vec<i64>, opens: &Vec<usize>, memo: &mut Vec<i64>) -> i64 {
    if bits == (1 << n) - 1 {
        return 0;
    }
    if memo[bits] != -1 {
        return memo[bits];
    }
    let m = costs.len();
    let mut ret = 1 << 60;
    for i in 0..m {
        let nbits = bits | opens[i];
        if bits == nbits {
            continue;
        }
        let nret = costs[i] + calc(n, nbits, costs, opens, memo);
        ret = std::cmp::min(ret, nret);
    }
    memo[bits] = ret;
    return ret;
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut costs = vec![0; m];
    let mut opens = vec![0; m];
    for i in 0..m {
        costs[i] = read::<i64>();
        let cnt = read::<usize>();
        for _j in 0..cnt {
            let v = read::<usize>() - 1;
            opens[i] |= 1 << v;
        }
    }
    let mut memo = vec![-1; 1 << n];
    let mut ans = calc(n, 0, &costs, &opens, &mut memo);
    if ans >= (1 << 60) {
        ans = -1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2172
//21
#include<iostream>
#include<algorithm>

using namespace std;

int n,l;
int c[100000];
int t[100000];
int a=0;

int gr(int i){
  if(t[i])return t[i];
  int li=(i==0||c[i-1]<c[i])?0:gr(i-1);
  int ri=(i==n-1||c[i+1]<c[i])?0:gr(i+1);
  t[i]=max(li,ri)+l-c[i];
  a=max(a,t[i]);
  return t[i];
}

int main(){
  cin>>n>>l;
  for(int i=0;i<n;i++){
    cin>>c[i];
  }
  for(int i=0;i<n;i++){
    gr(i);
  }
  cout<<a<<endl;
}

Measured memory_bytes: 3120
/*
@author: sharrad99
*/
#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	PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vbl vector<bool>
#define vpll vector<pll>
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(),x.end()
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define mod 1000000007
#define INF 1000000000000000
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set_pll;
#define ook order_of_key
#define fbo find_by_order
/*  
	Query 1 - order_of_key(k) : Number of items strictly smaller than k.
	Query 2 - find_by_order(k) : K-th element in the set (counting from zero).
	less<ll> means Query 1 will return numbers strictly less than k.
	greater<ll> means Query 1 will return numbers strictly greater than k.
*/
ll powmod(ll x, ll n){
	ll res = 1;
	while(n){
		if(n & 1){
			res *= x;
			res %= mod;
		}
		x *= x;
		x %= mod;
		n >>= 1;
	}
	return res;
}
ll invmod(ll a){
	return powmod(a, mod - 2);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n, k, res = 0;
	cin >> n >> k;
	ll r, s, p;
	cin >> r >> s >> p;
	string S;
	cin >> S;
	for(ll i = 0; i < k; i++){
		res += (S[i] == 'r' ? p : 0);
		res += (S[i] == 'p' ? s : 0);
		res += (S[i] == 's' ? r : 0);
	}
	for(ll i = k; i < n; i++){
		if(S[i] == S[i - k]){
			S[i] = 'x';
		}
		res += (S[i] == 'r' ? p : 0);
		res += (S[i] == 'p' ? s : 0);
		res += (S[i] == 's' ? r : 0);
	}
	cout << res << '\n';
}

Measured memory_bytes: 512
#include <iostream>
//#include <string>
//#include <vector>
//#include <cstdlib>
//#include <algorithm>
//include <cmath>
//#include <math.h>
using namespace std;
 
int main() {
    int A, B;
    int count = 0;
    
    cin >> A >> B;
    
    for(int i = A; i <= B; i++){
        int s = i % 10, t = i /10000 % 10, u = i / 10 % 10, v = i / 1000 % 10; 
        if(s == t && u == v) count++;
    }
    cout << count << endl;
    
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	string s;
	cin >> s;
	cout << s[0]<<s.length()-2 << s[s.length()-1];
	return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())

uf = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)

ans = 0

for i in range(uf.group_count()):
    ans = max(ans, uf.size(i))

print(ans)

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

int main() {
  long long N, D;
  cin >> N >> D;

  vector<long long> t, f;
  for (int i = 0; i < N; ++i) {
    long long a, b;
    cin >> a >> b;

    t.push_back(a);
    f.push_back(b - 1);
  }

  t.push_back(1001001001);
  f.push_back(0);

  if (t[0] < f[0]) {
    cout << -1 << endl;
    return 0;
  }

  long long ans = 0;
  long long m = 0;
  for (int i = 0; i < N; ++i) {

    long long d = t[i + 1] - t[i];
    m++;
    if (m > D) {
      cout << -1 << endl;
      return 0;
    }

    if (f[i] + f[i + 1] <= d) {
      ans += m * f[i];
      m = 0;
    }

    else if (abs(f[i + 1] - f[i]) <= d) {
      ans += m * d;
    }

    else {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4744
# yahoo-procon2019-qualC - When I hit my pocket...
def main():
    K, A, B = map(int, open(0).read().split())
    if B - A <= 2 or K < A - 1:  # corner case
        print(K + 1)
        return
    ans, K = A, K - (A - 1)
    if K % 2:
        K -= 1
        ans += 1
    ans += (B - A) * K // 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060