akhauriyash/Code-Regression huggingface dataset:
// Indrajeet Mishra
 
/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")*/
 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define test(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
#define debug(x) do { std::cerr << x; } while (0)
#define endl "\n"
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define dll deque<ll>
#define sll set<ll, greater <ll>>
#define mll map<ll, ll>
#define vii vector<int>
#define dii deque<int>
#define sii set <int, greater <int>>
#define mii map<int, int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define inv2 500000004
#define inv6 166666668
#define N 1000005
#define inf 200000000
#define eps 1e-10
#define PI 3.14159265359
#define all(v) (v).begin(),(v).end()
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define gcd(a,b) __gcd(a,b)
 
ll dp[101][101];
void dp_initialiser(){
    memset(dp,-1,sizeof(dp));
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //dp_initialiser();
    ll n=0;cin>>n;
    ll a[n]={0};
    rep(i,0,n)cin>>a[i];
    ll money=1000,stock=0;
    if(a[1]>a[0]){
        stock+=money/a[0];
        money%=a[0];
    }
    rep(i,1,n-1){
    	if(a[i-1]==a[i] && a[i+1]==a[i])continue;
        if(a[i-1]>=a[i] && a[i+1]>=a[i]){
            stock+=money/a[i];
            money%=a[i];
            continue;
        }
        if(a[i-1]<=a[i] && a[i+1]<=a[i]){
            money+=(stock*a[i]);
            stock=0;
        }
    }
    money+=(stock*a[n-1]);
    cout<<money;
    return 0;
}

Measured memory_bytes: 3576
program christmas_eve_eve_eve
  implicit none
  integer :: d
  read(*,*) d
  if (d .eq. 25) then
     write(*,'(a)') 'Christmas'
  else if (d .eq. 24) then
     write(*,'(a)') 'Christmas Eve'
  else if (d .eq. 23) then
     write(*,'(a)') 'Christmas Eve Eve'
  else
     write(*,'(a)') 'Christmas Eve Eve Eve'
  end if
  stop
end program christmas_eve_eve_eve

Measured memory_bytes: 768
#include<iostream>
#include<iomanip>
using namespace std;
 
int main(){
double PI = 3.14159265358979;
double r;
cin>>r;
cout<<fixed<<setprecision(20)<<r*r*PI<<" "<<setprecision(20)<<2*r*PI<<endl;
return 0;
}


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

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

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    int c = 0;
    bool all_even = true;
    while (all_even) {
        for (int i = 0; i < A.size(); i++) {
            if (A.at(i) % 2 == 0) {
                A.at(i) /= 2;
            }
            else {
                all_even = false;
                break;
            }
        }
        if (all_even)
            c++;
    }

    cout << c << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
p = list(map(int, input().split()))

X = 0
for i in range(1,n - 1):
    if p[i] < p[i + 1] and p[i - 1] < p[i] or p[i] < p[i - 1] and p[i + 1] < p[i]:
        X += 1
    else:
        X += 0
print(X)


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

using namespace std;

int main()
{
    double a, b, c, d, e, f, x, y;
    while (cin >> a >> b >> c >> d >> e >> f) {
        y = (a * f - c * d) / (a * e - b * d);
        x = (c - b * y) / a;
        printf("%.3f %.3f\n", x, y);
    }

    return 0;
}

Measured memory_bytes: 1236
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define rev reverse
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define endl '\n'
#define ull unsigned long long
#define sz(x) (int)x.size()

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll inf = 1e9+7;
const ll N = 1e5+1;
const ll mod = 1e9+7;
const ll P = 31;

int main() {
    IOS
    string s;
    cin >> s;
    if(s == "ABC") {
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3604
import java.io.*;
import java.util.Scanner;

public class Main{

	static long n;
	public static void main(String args[])throws Exception{
		Scanner sc=new Scanner(System.in);
			 n= sc.nextLong();
			 long sum=0;
			for(int i=1;i<=n;i++){
				if(i%3==0 || i%5==0){
					continue;
				}
				else
					sum+=i;
			}
			System.out.print(sum);
		}
	}



Measured memory_bytes: 35776
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
   
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
          return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
  
    public static bool bingo(bool[,] abool)
    {
        for (int i = 0; i < 3; i++)
        {
            if (abool[0, i] && abool[1, i] && abool[2, i])
                return true;
        }
        for (int i = 0; i < 3; i++)
        {
            if (abool[i,0] && abool[i,1] && abool[i,2])
                return true;
        }
        
        for (int i = 0; i < 3; i++)
        {
            if ((abool[0, 0] && abool[1, 1] && abool[2, 2]) || abool[0, 2] && abool[1, 1] && abool[2, 0])
                return true;
        }
        

        return false;

    }
    public static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        var a = new long[3, 3];
        var abool = new bool[3, 3];
        for(int i = 0; i < 3; i++)
        {
            var input = Reads();
            for (int j = 0; j < 3; j++)
            {
                a[i, j] = input[j];
                abool[i, j] = false;
            }
        }
       
        var n = Read();
        var b = new long[n];
        for (int j = 0; j < n; j++)
        {
            b[j] = Read();
        }
        for (int k = 0; k < n; k++)
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (a[i, j] == b[k])
                        abool[i, j] = true;
                }
            }
        }
        if (bingo(abool))
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");

          
        Console.Out.Flush();

    }
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int32_t main(){
   int a,b,c;
   cin>>a>>b>>c;
   if(b>a)
   swap(a,b);
   if(b<=c && c<=a)
   cout<<"Yes";
   else
   cout<<"No";
  return 0;
}


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

int main()
{
  int a,b;
  cin>>a>>b;
  char x[10],y[10],z;
  for(int i=1; i<=a; i++)
  {
    cin>>x[i];
    if(x[i]=='-')
    {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cin>>z;
  if(z!='-')
  {
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=1; i<=b; i++)
  {
    cin>>y[i];
    if(y[i]=='-')
    {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
high = list(map(int, input().split()))

judge = ["ok" for i in range(n)]

for i in range(m):
    a, b = [int(s) - 1 for s in input().split()]

    if high[a] < high[b]:
        judge[a] = "ng"
    elif high[a] > high[b]:
        judge[b] = "ng"
    else:
        judge[a] = "ng"
        judge[b] = "ng"

print(judge.count("ok"))


Measured memory_bytes: 20100
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);
        ABC170_a solver = new ABC170_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC170_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            for (int i = 0; i < 5; i++) {
                int into = in.nextInt();
                if (into == 0) {
                    out.println(i + 1);
                    return;
                }

            }

        }

    }
}



Measured memory_bytes: 35788
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  const int MOD=1e9+7;
  const int N=2e5+2;

  int32_t main()
  {
    
      
       IOS
       int x,y,d,t,ans=0;
       cin>>t>>d;
       //d=d*d;
       //cout<<d;
       while(t--)
       {
        cin>>x>>y;
        //cout<<sqrt(x*x + y*y)<<" "<<d<<endl;
        if(sqrt(x*x + y*y) <= d)
          ans++;
        //trace2(x*x + y*y,d);

       }
       cout<<ans;
       return 0;
    }




Measured memory_bytes: 3696
read = input 
rn = lambda :list(map(int, read().split()))
# O(N^2)
n, k = rn()
V = rn() # 0 ~ n-1
best = 0
for i in range(0, n + 1): # [0, n]
    for j in range(i, n+1): # [i + 1, n]
        # take [0,i), [j, n)
        yes = V[0:i] + V[j: n]
        if len(yes) > k:
            continue
        leftout = k - len(yes)
        yes.sort()
        skip = 0
        for skip in range(len(yes)):
            if yes[skip] <0 and leftout > 0:
                leftout -= 1
            else :
                break
        if best < sum(yes[skip:]):
            best = sum(yes[skip:])
#             print(yes[skip:], k, best)
print(best)

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  ll a, b; cin >> a >> b;
  // string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = a + b;
  // bool ok = false;
  chmax(ans, a - b);
  chmax(ans, a * b);
   cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3628
a=int(input())
b=int(input())
c=int(input())
x=int(input())
print(len([x-500*i-100*j-50*k for k in range(c+1) for j in range(b+1) for i in range(a+1) if x-500*i-100*j-50*k==0]))
            

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

void b_theater(void) {
	int n;
	int l, r;
	cin >> n;

	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> l >> r;
		int person = r - l;
		sum += (person+1);
	}

	cout << sum << endl;
}

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

Measured memory_bytes: 3584
N, M = map(int, input().split())
root = [[] for _ in range(N+1)]
 
for i in range(M):
    a, b = map(int, input().split())
    root[a].append(b)
    root[b].append(a)
 
ans = [10**9] * (N+1)
ans[0] = 0
ans[1] = 0
 
from collections import deque
q = deque([1])
 
while q:
    p = q.popleft()
    for i in root[p]:
        if ans[i] == 10**9:
            ans[i] = p
            q.append(i)
 
if 10**9 in set(ans):
    print('No')
else:
    print('Yes')
    for i in range(2, N+1):
        print(ans[i])

Measured memory_bytes: 97288
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <cassert>

using namespace std;

vector<int> memo;

int dfs(int x) {
	assert(x >= 0);

	if (memo[x] != -1) {
		return memo[x];
	}

	int tmp = __builtin_popcount(x);
	int x2 = x % tmp;
	memo[x] = dfs(x2) + 1;
	return memo[x];
}

vector<int> calc_0to1(string s) {
	int n = s.size();
	vector<int> vals(n, -1);
	int mod = count(s.begin(), s.end(), '1') + 1;

	int x = 0;
	for (int i = 0; i < n; i++) {
		x = x * 2 + (s[i] == '1' ? 1 : 0);
		x %= mod;
	}
	int base_val = x;

	int pow2 = 1;
	for (int i = 0; i < n; i++) {
		int idx = n - i - 1;
		if (s[idx] == '0') {
			vals[idx] = (base_val + pow2) % mod;
		}
		pow2 = pow2 * 2 % mod;
	}

	return vals;
}

vector<int> calc_1to0(string s) {
	int n = s.size();
	vector<int> vals(n, -1);
	int mod = count(s.begin(), s.end(), '1') - 1;
	if (mod == -1) {
		return vals;
	} else if (mod == 0) {
		for (int i = 0; i < n; i++) {
			if (s[n - i - 1] == '1') {
				vals[i] = 0;
			}
		}
		return vals;
	}

	int x = 0;
	for (int i = 0; i < n; i++) {
		x = x * 2 + (s[i] == '1' ? 1 : 0);
		x %= mod;
	}
	int base_val = x;

	int pow2 = 1;
	for (int i = 0; i < n; i++) {
		int idx = n - i - 1;
		if (s[idx] == '1') {
			int val = base_val - pow2;
			if (val < 0) {
				long long tmp = val;
				tmp += 1LL * pow2 * mod;
				tmp %= mod;
				val = tmp;
			}
			vals[idx] = val;
		}
		pow2 = pow2 * 2 % mod;
	}

	return vals;
}


int main() {
	int n;
	string x;
	cin >> n >> x;
	memo.assign(n+1, -1);
	memo[0] = 0;

	int n1 = count(x.begin(), x.end(), '1');

	auto v_0to1 = calc_0to1(x);
	auto v_1to0 = calc_1to0(x);

	// for (int i = 0; i < n; i++) {
	// 	printf("i %2d: 0to1 %3d, 1to0 %3d\n", i, v_0to1[i], v_1to0[i]);
	// }

	vector<int> ans(n);
	for (int i = 0; i < n; i++) {
		if (x[i] == '0') {
			ans[i] = dfs(v_0to1[i]) + 1;
		} else {
			if (n1 == 1) {
				ans[i] = 0;
			} else {
				ans[i] = dfs(v_1to0[i]) + 1;
			}
		}
	}

	for (auto z: ans) {
		cout << z << endl;
	}

	return 0;
}


Measured memory_bytes: 6380
#include <iostream>
#include <queue>
#include <string>
using namespace std;
typedef pair<string,int> Psi;

int main(){
	int n,q;
	cin >> n >> q;
	queue<Psi> Q;
	for(int i=0; i<n; ++i){
		Psi tmp;
		cin >> tmp.first >> tmp.second;
		Q.push(tmp);
	}
	int cnt = 0;
	while(! Q.empty()){
		Psi t = Q.front();
		Q.pop();
		if(t.second > q){
			t.second -= q;
			Q.push(t);
			cnt += q;
		} else {
			cnt += t.second;
			cout << t.first << " " <<cnt << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4404
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var h = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        Console.WriteLine(count(h));
    }

    static int count(IEnumerable<int> seq)
    {        
        if(seq.Any() == false)
        {
            return 0;
        }

        var ans = seq.Min();
        
        seq = seq.Select(n => n - ans).ToArray();

        while(seq.Any())
        {
            ans += count(seq.TakeWhile(n => n != 0));
            seq = seq.SkipWhile(n => n != 0).SkipWhile(n => n == 0);
        }

        return ans;
    }
    
}

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

struct st { int a, b, c; };
vector<st>E[10000];
int d[10000], c[10000];
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, n)E[i].clear();
		rep(i, m) {
			int u, v, d, c; scanf("%d%d%d%d", &u, &v, &d, &c); u--; v--;
			E[u].push_back({ v,d,c }); E[v].push_back({ u,d,c });
		}
		memset(d, 0x3f, sizeof(d));
		priority_queue<P>que;
		d[0] = 0; que.push(P(0, 0));
		while (!que.empty()) {
			P p = que.top(); que.pop();
			for (st&v : E[p.second]) {
				if (d[v.a] > p.first + v.b) {
					d[v.a] = p.first + v.b;
					c[v.a] = v.c;
					que.push(P(d[v.a], v.a));
				}
				else if (d[v.a] == p.first + v.b&&c[v.a] > v.c)c[v.a] = v.c;
			}
		}
		printf("%d\n", accumulate(c, c + n, 0));
	}
}

Measured memory_bytes: 5100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int P=1e9+7,N=1002;
int n,m,a[N][N],i,j,lr,ud,v,cnt;
ll k;
char s[N];
int pw(int x,ll y){int z=1;for(;y;y>>=1,x=1ll*x*x%P)if(y&1)z=1ll*z*x%P;return z;}
struct M{
	int a[2][2];
	friend M operator*(M x,M y){
		M z;
		for (int i=0;i<2;i++)
			for (int j=0;j<2;j++) z.a[i][j]=(1ll*x.a[i][0]*y.a[0][j]+1ll*x.a[i][1]*y.a[1][j])%P;
		return z;
	}
	friend M operator^(M x,ll y){
		M z;z.a[0][0]=z.a[1][1]=1;
		z.a[0][1]=z.a[1][0]=0;
		for (;y;y>>=1,x=x*x)
			if (y&1) z=z*x;
		return z;
	}
}A,B;
int main(){
	scanf("%d%d%lld",&n,&m,&k);
	for (i=1;i<=n;i++){
		scanf("%s",s+1);
		for (j=1;j<=m;j++) a[i][j]=s[j]=='#',v+=a[i][j];
	}
	for (i=1;i<=n;i++) lr+=a[i][1]&a[i][m];
	for (i=1;i<=m;i++) ud+=a[1][i]&a[n][i];
	if (!lr && !ud) printf("%d",pw(v,k-1));
	else if (lr && ud) puts("1");
	else{
		for (i=1;i<=n;i++)
			for (j=1;j<=m;j++) cnt+=a[i][j]&(lr?a[i][j+1]:a[i+1][j]);
		B.a[0][1]=1;
		A.a[0][0]=lr+ud,A.a[1][0]=cnt,A.a[1][1]=v;
		B=B*(A^(k-1));
		printf("%d",(B.a[0][1]-B.a[0][0]+P)%P);
	}
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,D;
	cin >> N >> D;
	VV<int> x(N,V<int>(D));
	rep(i,N) rep(j,D) cin >> x[i][j];
	int ans = 0;
	V<bool> iss(1000000);
	rep1(i,999) iss[i*i] = true; 
	rep(i,N) rep(j,i){
		int s = 0;
		rep(d,D) s += (x[i][d] - x[j][d]) * (x[i][d] - x[j][d]);
		if(iss[s]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i)
p(6484)
a(0,1,3)
a(2,3,3,1)
for x in 0,1:
	a(x,3,x)
	for t in r(30):b(v:=x+4);a(v,3,6),*map(b,[6]*(29-t));a(6,x,T:=x*60+35+t,1);a(v,T,v)
for t in r(60):b(2);[(a(34+t-s,95+s,5),a(3,5,6,1),a(2,6,2))for s in r(t)]

Measured memory_bytes: 9268
import heapq
import numpy as np

N, M = [int(x) for x in input().split(" ")]

e = {i: [] for i in range(N)}
for _ in range(M):
  a, b = [int(x)-1 for x in input().split(" ")]
  e[a].append(b)
  e[b].append(a)

d = np.ones(N, dtype=int) * -1
q = [0]
while len(q) != 0:
  v = q.pop(0)
  for ne in e[v]:
    if d[ne] == -1:
      d[ne] = v
      q.append(ne)

print("Yes")
# for p in prev[1:]:
#   print(p+1)
# print("\n".join([str(p+1) for p in d[1:]]))
for p in d[1:]:
  print(p+1)


Measured memory_bytes: 59708
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i= 0 ;i < (n) ; ++i)
 
int main() {
    int n;
  cin >> n;
  vector<int> B(n-1);
  rep(i,n-1) cin>>B[i];
  vector<int> A(n);
  A[0]=B[0];
  for(int i = 1 ; i <= n-2 ; i++){
    A.at(i)=min(B.at(i),B.at(i-1));
  }
  A.at(n-1)=B.at(n-2);
 
int ans = 0;
   rep(i,n) ans += A.at(i);
   cout << ans << endl;
return 0;
 
 
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
a = []
b = []
ans = 0
for i in range(N):
    a.append(i+1+A[i])
    b.append(i+1-A[i])
b = Counter(b)
for i in a:
    ans += b[i]
print(ans)

Measured memory_bytes: 134704
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

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


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        vector<int> v(3);
        rep(i, 0, 3) cin >> v[i];
        sort(all(v));
        int ans = v[1] + v[0];
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
R,G,B,N=map(int,input().split())
 
res = 0
for i in range(0, N//R + 1):
    for j in range(0, (N-i*R)//G + 1):
        if (N-i*R-j*G)%B == 0:
            res+=1
 
print(res)

Measured memory_bytes: 2940
#include <stdio.h>

#define MAX_N 150

int max(int a, int b) {
  return a > b ? a: b;
}

int main(void) {

  int x =0;
  int n;
  char s[MAX_N];
  int max_x;
  int i;

  max_x = x;

  scanf("%d", &n);
  scanf("%s", s);

  for(i = 0; i < n; i++) {
    if(s[i] == 'I') x++;
    else x--;
    max_x = max(max_x, x);
  }

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

  return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll a, b; cin >> a >> b;
    if(a != 0) a--;

    ll tmp = a % 4;
    ll tmp2 = b % 4;
    ll x, y;
    if(tmp == 0){
        x = a;
    }else if(tmp == 1){
        x = 1;
    }else if(tmp == 2){
        x = a + 1;
    }else{
        x = 0;
    }

    if(tmp2 == 0){
        y = b;
    }else if(tmp2 == 1){
        y = 1;
    }else if(tmp2 == 2){
        y = b + 1;
    }else{
        y = 0;
    }

    cout << (x ^ y) << endl;
    
}

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

int main() {
  int N;
  cin>>N;
  long double sum=0;
  for(int i=0;i<N;i++){
    long double A;
    cin>>A;
    sum+=1.0/A;
  }
  cout<<fixed<<setprecision(10)<<1.0/sum<<endl;
      
}

Measured memory_bytes: 3768
fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut count = 0;
    for i in 0..n - 2 {
        if s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C' {
            count += 1;
        }
    }
    println!("{}", count);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import sys
from bisect import bisect_left, bisect_right
import itertools

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
#print("A={}".format(A))
"""
この問題の前半は、合計の幸福度Xが上位M個未満に入るかを判定する。
    -> Xに関する二分探索をすることで、上位から丁度M番目の幸福度がわかる！

これを判定するために、左手の握手先をfix(A[i]とする)して、
右手の幸福度が(X - A[i])以上であるものの個数を数える。
"""

def within(X, M):
    """
    幸福度がX以上上がるような握手の組がM個未満ならTrue、そうでなければFalseを返す
    """
    pair = 0
    for i in range(N):
        idx = bisect_left(A, X - A[i])
        pair += N - idx
    if pair < M:
        #print("pair={}<M".format(pair))
        return True
    else:
        #print("pair={}>=M".format(pair))
        return False

"""
Xに関する二分探索をおこなった結果、
leftXはwithin(leftX, M) == Trueになる最小のX
"""
leftX = 0
rightX = A[-1] * 2 + 1
while leftX != rightX:
    middleX = (leftX + rightX) // 2
    #print("mid={}".format(middleX))
    if within(middleX, M):
        rightX = middleX
    else:
        leftX = middleX + 1
#print("leftX={}".format(leftX))

"""
これより後半、幸福度の総和を求める。
前半同様に左手をfixした上で、両手の幸福度の合計がleftX以上になるときの幸福度を加算していく。
単純に右手に関してfor文を回して加算するとTLEなので、
右手の幸福度に関しては先に累積和を求めておく。
"""
S = list(itertools.accumulate(A))
#print("S={}".format(S))
happy = 0
times = 0
for i in range(N):
    idx = bisect_left(A, leftX - A[i])
    times += N - idx
    #print("When i={}, idx={}, times={}".format(i, idx, times))
    if idx != 0:
        happy += A[i] * (N - idx) + (S[-1] - S[idx - 1])
    else:
        happy += A[i] * (N - idx) + S[-1]
    #print("happy={}".format(happy))
happy += (leftX - 1) * (M - times)

print(happy)


Measured memory_bytes: 59916
"""
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

A.sort()


def bisect(i,V):
    l = i+1
    r = N-1
    if A[i]*A[r]<V:
        return r-i
    if [i]*A[l]>=V:
        return 0
    while r-l>1:
        if A[i]*A[(l+r)//2]<V:
            l = (l+r)//2
        else:
            r = (l+r)//2
    return r

"""


N = input()
N = N[::-1]

count = 0
flag = False
for i in range(len(N)):
    s = int(N[i])
    if not flag:

        if s>5:
            count += 10-s
            flag = True
        elif s==5:
            count += 5
            if i<len(N)-1:
                t = int(N[i+1])
                if t>=5:
                    flag=True
        else:
            count += s
            flag=False
    else:

        if s+1>=10:
            #A.append("0")
            #B.append("0")
            flag = True
        elif s+1>5:
            count += 10-s-1
            #A.append("0")
            #B.append(str(10-s-1))
            flag = True
        elif s+1==5:
            count += 5
            if i<len(N)-1:
                t = int(N[i+1])
                if t>=5:
                    flag=True
                else:
                    flag=False
            else:
                flag=False

        else:
            count += s+1

            flag=False

if flag:
    count+=1

print(count)


Measured memory_bytes: 58352
#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

int main () {
    int n;
    int a, b, c;
    
    cin >> n;
    int dp[n+1][3];
    vector<vector<int>> arr(n);
    
    for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++)
      dp[i][j] = 0;
    
    for (int i = 0; i < n; i++) {
        cin >> a >> b >> c;
        arr[i].push_back(a);
        arr[i].push_back(b);
        arr[i].push_back(c);
    }
    
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
   
    for (int i = 1; i < n ; i++) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + arr[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + arr[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + arr[i][2];
    }
    cout  << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}



Measured memory_bytes: 6912
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <sstream>
#include <vector>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	if ((N + 1) / 2 >= K)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
INF = 10**18


if __name__ == "__main__":
    c = list(input())
    t = list(input())
    for i in range(len(c)):
        if c[i] != t[len(t)-i-1]:
            print("NO")
            sys.exit()
    print("YES")
        

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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

struct RMQ {
    vector<ll> data;
    ll N;
    RMQ(ll size) {
        N = 1;
        while(N < size) N *= 2;
        data.assign(2*N - 1, LLINF/2);
    }
    // 0オリジンでk番目の要素をaに変更する
    void update(ll k, ll a) {
        k += N - 1; // 葉に移動
        data[k] = a;
        while(k > 0) {
            k = (k - 1)/2;
            data[k] = min(data[2*k + 1], data[2*k + 2]);
        }
    }
    // minimum [a, b)
    ll minimum(ll a, ll b) {
        return minimum_sub(a, b, 0, 0, N);
    }
    ll minimum_sub(ll a, ll b, ll k, ll l, ll r) {
        if(r <= a || b <= l) return LLINF/2;
        if(a <= l && r <= b) return data[k];

        return min(minimum_sub(a, b, 2*k + 1, l, (l + r)/2),
                   minimum_sub(a, b, 2*k + 2, (l + r)/2, r));
    }
};

int main(){

  ll n, c;
  cin >> n >> c;
  vector<pair<ll, ll>> xv(n);
  rep(i, n) cin >> xv[i].first >> xv[i].second;

  vector<ll> sum1(n), sum2(n);
  struct RMQ rmq1(n), rmq2(n);

  ll sum = 0;
  rep(i, n){
    sum += (xv[i].second - (xv[i].first - (i == 0 ? 0 : xv[i-1].first)));
    rmq1.update(i, -sum);
    sum1[i] = sum;
  }
  sum = 0;
  for(int i = n - 1; i >= 0; i--){
    sum += (xv[i].second - ((i == n-1 ? c : xv[i+1].first) - xv[i].first));
    rmq2.update(i, -sum);
    sum2[i] = sum;
  }

  ll ans = 0;
  rep(i, n){
    ans = max(ans, sum1[i] + max(0LL, -rmq2.minimum(i + 1, n) - xv[i].first));
    ans = max(ans, sum2[n - 1 - i] + max(0LL, -rmq1.minimum(0, n - 1 - i) - (c - xv[n - 1 - i].first)));
  }

  cout << ans << endl;

	return 0;
}


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

int main() {
    ll K, A, B;
    cin >> K >> A >> B;
    bool ans = false;
    REP(i, 1001){
        if(K * i >= A && K * i <= B){
            ans = true;
        }
    }

    if(ans == true){
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
}

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

ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k == x:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long 
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e7+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{

	  ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int a, b;
    string s;
    int ans=0;
    int d;
    cin>>a>>b>>d;
    for(int i=a;i<=b;i++)
    if(i%d==0)ans++;
  cout<<ans;
  
}

Measured memory_bytes: 3604
#include <cstdio>
const int N = 1e5 + 5;
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
int n, len, a[N], id;
int main() {
	n = Get(), len = Get();
	for (int i = 1; i <= n; ++i) a[i] = Get();
	for (int i = n - 1; i; --i)
		if (a[i] + a[i + 1] >= len) id = i;
	if (!id) puts("Impossible");
	else {
		puts("Possible");
		a[len = 1] = id;
		for (int i = id - 1; i; --i) a[++len] = i;
		for (int i = id + 1; i < n; ++i) a[++len] = i;
		for (int i = len; i; --i) printf("%d\n", a[i]);
	}
}

Measured memory_bytes: 1152
import numpy as np
import numba


@numba.jit('i8[:](i8, i8[:], i8[:, :], i8[:])')
def solve(dd, c_arr, s_arr, t_arr):
    last_d = np.zeros(26, dtype=np.int64) - 1
    score = 0
    score_arr = np.zeros(dd, dtype=np.int64)
    for d in range(dd):
        score += s_arr[d, t_arr[d] - 1]
        last_d[t_arr[d] - 1] = d
        score -= (c_arr * (d - last_d)).sum()
        score_arr[d] = score
    return score_arr


def main():
    d = np.int64(input())
    c_arr = np.array(list(map(int, input().split()))).astype(np.int64)
    s_arr = np.array([list(map(int, input().split())) for _ in range(d)]).astype(np.int64)
    t_arr = np.array([int(input()) for _ in range(d)]).astype(np.int64)
    res = solve(d, c_arr, s_arr, t_arr)
    for r in res:
        print(r)


if __name__ == "__main__":
    main()


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

int main() {
  vector<char> data(4);
  for (int i = 0; i < 4; i++) {
    cin >> data.at(i);
  }

  // 答えを保持する変数
  int answer = 0 ;

  for (int i = 0; i < 4; i++) {

    if (data.at(i) == '2' ) {
      answer++;
    }

  }

  cout << answer << endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

ll MOD;

const int MAX_N = 112345;
vector<int> g[MAX_N];
vector<ll> dp[MAX_N];

ll dfs1(int v, int prev) {
  ll res = 1;
  REP(i, g[v].size()) {
    int u = g[v][i];
    if (u != prev) {
      dp[v][i] = dfs1(u, v);
      res *= (1 + dp[v][i]);
      res %= MOD;
    }
  }
  return res;
}

void dfs2(int v, int prev, ll X) {
  REP(i, g[v].size()) {
    int u = g[v][i];
    if (u == prev) {
      dp[v][i] = X;
    }
  }

  int K = (int)g[v].size();
  vector<ll> L(K + 1);
  vector<ll> R(K + 1);

  L[0] = 1;
  REP(i, K) L[i+1] = L[i] * (1 + dp[v][i]) % MOD;
  R[K] = 1;
  for (int i = K-1; i >= 0; i--) R[i] = R[i+1] * (1 + dp[v][i]) % MOD;

  REP(i, g[v].size()) {
    int u = g[v][i];
    if (u != prev) {
      ll Y = L[i] * R[i+1] % MOD;
      dfs2(u, v, Y);
    }
  }

}

int main2() {
  REP(i, MAX_N) g[i].clear();
  REP(i, MAX_N) dp[i].clear();
  int N = nextInt();
  MOD = nextInt();

  REP(i, N-1) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  REP(i, N) dp[i].resize(g[i].size());

  if (N==1) {
    cout << 1 % MOD << endl;
    return 0;
  }
  if (N==2) {
    cout << 2 % MOD << endl;
    cout << 2 % MOD << endl;
    return 0;
  }

  int root = -1;
  REP(i, N) if (g[i].size() >= 2) { root = i; break; }
  dfs1(root, -1);
  dfs2(root, -1, 0);
  REP(v, N) {
    ll ans = 1;
    REP(i, g[v].size()) {
      ans = (ans * (1 + dp[v][i])) % MOD;
    }
    printf("%d\n", (int)ans);
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

int main(){
    ll h,w;
    cin>>h>>w;
    vector<vector<ll>> c(10,vector<ll>(10));
    rep(i,10){
        rep(j,10){
            cin>>c[i][j];
        }
    }
    vector<vector<ll>> a(w,vector<ll>(h));
    rep(i,h){
        rep(j,w){
            cin>>a[j][i];
        }
    }
    rep(k,10){
        rep(i,10){
            rep(j,10){
                c[i][j]=min(c[i][k]+c[k][j],c[i][j]);
            }
        }
    }
    ll sum=0;
    rep(i,w){
        rep(j,h){
            if(a[i][j]!=-1){
                sum+=c[a[i][j]][1];
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Tuple = tuple<int, int, int>;


int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.rbegin(), a.rend());

    int al=0, bo=0;
    rep(i, n) {
        if(i%2==0) al += a[i];
        else bo += a[i];
    }

    cout << max(al-bo, 0) << endl;

    return 0;

}


Measured memory_bytes: 256
import sys


INF = 10**60
inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

k, a, b = inintm()
ans = 0

if a + 2 >= b:
    print(1+k)
else:
    ch = max(0, (k-(a-1))//2)
    print(b + (ch-1)*(b-a) + k-(ch*2+a-1))


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

using namespace std;

const int INF = 1000000000;

int main(){
    int T;
    cin >> T;
    while(T--) {
        int n;
        cin >> n;
        vector<int> a(n);
        REP(i, n) cin >> a[i];

        int dp[101][101] = {};
        REP(i, n) REP(j, n) dp[i][j] = -INF;
        REP(i, n) dp[i][i] = 0;
        for(int l = 1; l < n; l++) {
            for(int i = 0; i < n; i++) {
                int j = (i + l) % n;
                int max_k = 0;
                for(int h = 0; h < l; h++) {
                    int k = (i + h) % n;
                    int k2 = (i + h + 1) % n;
                    int val = dp[i][k] + dp[k2][j] + abs(a[i] - a[k2]);
                    if(dp[i][j] < val) {
                        max_k = k;
                        dp[i][j] = val;
                    }
                }
                //printf("dp[%d][%d] = %d (dp[%d][%d] + dp[%d][%d])\n", i, j, dp[i][j], i, max_k, (max_k + 1) % n, j);
            }
        }

        int ans = -INF;
        REP(i, n) ans = max(ans, dp[i][(i + n - 1) % n]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>

class Dice{
public:
	Dice(){
		number = new int[6];
		work = new int[6];
	};

	void setLabel(int index,int num){
		number[index] = num;
	};

	void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'N':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'S':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	int returnPeek(){
		return number[0];
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

private:
	int* number;
	int* work;
};

int main(){
	Dice dice;
	int label;
	char ch;
	for(int i = 0; i < 6; i++){
		scanf("%d",&label);
		dice.setLabel(i,label);
	}
	getchar(); 
	while((ch = getchar()) != '\n'){
		dice.roll(ch);
	}
	printf("%d\n",dice.returnPeek());
}



Measured memory_bytes: 2756
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{
  vector<int>parent,sizes;
  UnionFind(int n):parent(n),sizes(n,1){
    for(int i=0;i<n;++i)parent[i]=i;
  }
  int find(int x){
    return x==parent[x]?x:parent[x]=find(parent[x]);
  }
  void unite(int x,int y){
    if((x=find(x))==(y=find(y)))return;
    if(sizes[x]>sizes[y])swap(x,y);
    parent[y]=x;
    sizes[x]+=sizes[y];
    sizes[y]=0;
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  int size(int x){
    return sizes[find(x)];
  }
};
int main(){
  int N,Q;
  cin>>N>>Q;
  UnionFind UF(N);
  for(int i=0;i<Q;++i){
      int c,x,y;
      cin>>c>>x>>y;
      if(c) cout<<UF.same(x,y)<<endl;
      else UF.unite(x,y);
  }
}

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

int main(){
  int N;
  cin>>N;
  int A[N];
  for (int i=0;i<N;i++){
    cin>>A[i];
  }
  int count=0;
  
  for (int i=0;i<N;i++){
    while(A[i]%2==0){
      count++;
      A[i]=A[i]/2;
    }
  }
      
  cout<<count<<endl;
  return 0;
}



  

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;


fn main() {
    proconio::input! {
        n: usize,
        mut p: [isize;n],
        }
    let mut q: [isize;1000000] = [0;1000000];
    q[1]=(p[1]-p[0]).abs();
    for i in 2..n {
        q[i]=min((p[i]-p[i-2]).abs()+q[i-2],(p[i]-p[i-1]).abs()+q[i-1]);
    }
    println!("{}",q[n-1]);
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> cnt(101);
    cnt[a]++, cnt[b]++, cnt[c]++;

    int res = 0;
    for (int i = 0; i < 101; i++) {
        if (cnt[i]) res++;
    }

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

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int tc=1;
		while(tc-->0){
			System.out.println((int)Math.pow(Integer.parseInt(br.readLine()),2));
		}
	}
}

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

int main() {
  int h,n; cin>>h>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];
  int sum=0;
  rep(i, n) sum+=a[i];
  if (h-sum<=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> c(n-1), s(n-1), f(n-1);
  REP(i, n-1) cin >> c[i] >> s[i] >> f[i];
  vector<ll> ans(n);
  REP(i, n-1){
    ll now = 0;
    FOR(j, i, n-1){
      if(now <= s[j]){
      now = s[j];
    }else{
      if(now%f[j] != 0){
        now += f[j] - (now % f[j]);
      }
    }
    now += c[j];
    }
    ans[i] = now;
  }
  ans[n-1] = 0;
  REP(i, n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
	Scanner scan = new Scanner(System.in);
	int d = scan.nextInt();
	int n = scan.nextInt();
	int anser = (int)Math.pow(100, d) * n;
	if (anser ==  Math.pow(100, d) * 100) {
	    System.out.println(anser + (int)Math.pow(100, d));
	} else {
	    System.out.println(anser);
	}
    }
}


Measured memory_bytes: 22612
n , m = map(int,input().split())
a , b = 1 , 100000

for i in range(m):
    l , r = map(int,input().split())
    if a <= l:
        a = l
    if b >= r:
        b = r
        
c = b - a + 1
if c > 0:
    print(c)
else:
    print(0)

Measured memory_bytes: 3060
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        int plus = a + b;
        int minus = a - b;
        int mult = a * b;

        if (plus > minus) {
            if (plus > mult) {
                System.out.println(plus);
            } else {
                System.out.println(mult);
            }
        } else if (minus > plus) {
            if (minus > mult) {
                System.out.println(minus);
            } else {
                System.out.println(mult);
            }
        } else {
            System.out.println(plus);
        }
    }
}

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

int main() {
    string A, B, C;
    cin >> A >> B >> C;

    if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <string>
#include <ios>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	long double N, K;
	cin >> N >> K;

	long double  k = 2;
	long double  result = 0;

	for (int n = 1; n <= N; n++) {
		k = ceil(log2(K / n));
		if (k >= 1) {
			result += pow(0.5, k);
		}
		else {
			result += 1;
		}
	}

	cout << std::setprecision(20) <<result/N << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2e5+5;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,x;cin>>n>>x;
    if(x==1 || x==2*n-1)return cout<<"No" , 0;
    cout<<"Yes\n";
    vector< ll > ans(2*n-1);
    for(ll i=0;i<2*n-1;i++)ans[i]=i+1 ;
    swap(ans[x-1],ans[n-1]);
    swap(ans[0],ans[n-2]);
    swap(ans[2*n-2],ans[n]);
    for(ll i=0;i<2*n-1;i++)cout<<ans[i]<<"\n";
}



Measured memory_bytes: 3072