akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main() {
    int A, B, K;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

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

int main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,X; cin >> N >> X;
	struct test{
		ll b,l,u,c;
		test(ll b,ll l,ll u,ll c):b(b),l(l),u(u),c(c){}
		bool operator<(const test &t) const{
			return c>t.c;
		}
	};
	vector<test> ts;
	ll sum=0;
	for (int i=0;i<N;++i){
		ll b,l,u; cin >> b >> l >> u;
		ts.emplace_back(b,l,u,u*(X-b)+l*b);
		sum+=l*b;
	}
	sort(ts.begin(),ts.end());
	ll lb=-1,ub=N*X;
	while(ub-lb>1){
		ll mid=(ub+lb)>>1LL;
		ll cnt=0;
        for (int i=0;i<mid/X;++i) cnt+=ts[i].c;
        int ok=0;
        for (int i=0;i<N;++i){
            test t=ts[i];
            ll cnt0=cnt;
            if (i<mid/X) cnt0+=ts[mid/X].c-t.c;
            if (mid%X<t.b) cnt0+=t.l*(mid%X);
			else cnt0+=t.u*(mid%X-t.b)+t.l*t.b;
            if (cnt0>=sum) ok=1;
        }
		(ok?ub:lb)=mid;
	}
	cout << ub << '\n';
}

Measured memory_bytes: 6512
while ((n,x = gets.split(" ").map(&:to_i)).inject(:+) != 0) do
  count = 0
  catch(:stop) do
    n.downto(1) do |n1|
      (n1-1).downto(1) do |n2|
        n3 = x - n1 - n2
        count += 1 if (n3 < n2) && (n3 > 0)
        throw :stop if (n3 > n1)
        break if (n3 > n2)
      end
    end
  end
  puts count
end

Measured memory_bytes: 8608
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main(){
    string s; cin >> s;
    int n = s.size();
    //cout << "n:" << n << endl;
    const int w = 2019;
    int cnt = 1;
    vector<int> mod(n);
    rep(i,n){
        string c = s.substr(n-1-i,1);
        int a = stoi(c); //cout << a << " ";
        mod[n-1-i] = cnt * a % w;
        cnt *= 10; cnt %= w;
    }
    vector<int> rui(n);
    rui[n-1] = mod[n-1];
    repp(i,n,1) rui[n-1-i] = (rui[n-i] + mod[n-1-i]) % w;
    //printvec(rui);
    vector<int> sou(w,0);
    rep(i,n) sou[rui[i]]++;
    int ans = sou[0] * (sou[0] + 1) / 2;
    repp(i,w,1) ans += sou[i] * (sou[i] - 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	int n;
	cin>>n;
	int dp[n][3];
	rep(i,n){
		int a,b,c;
		cin>>a>>b>>c;
		if(i==0){
			dp[i][0]=a;
			dp[i][1]=b;
			dp[i][2]=c;
			continue;
		}
		dp[i][0]=max(dp[i-1][1]+a,dp[i-1][2]+a);
		dp[i][1]=max(dp[i-1][0]+b,dp[i-1][2]+b);
		dp[i][2]=max(dp[i-1][1]+c,dp[i-1][0]+c);
	}
	int ans=max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
	puts(ans);
}


Measured memory_bytes: 4764
n, x, m = map(int, input().split())

loop = [0]*m

a = x
is_loop = False
for i in range(n):
        if loop[a] == 1:
            # あまりがループしている
            loop[a] += 1
            is_loop = True
            break
        else:
            # ループしていない
            loop[a] = 1
            a = (a**2)%m

if not is_loop:
    # ループしなかった
    ans = 0
    for i in range(m):
        ans += i*loop[i]
    print(ans)
else:
    # ループした
    # 1. ループ長を求める
    def get_loop_length(b):
        c = 1
        s = b
        b_tmp = b
        while True:
            b_tmp = (b_tmp**2)%m
            if b == b_tmp:
                return c, s
            else:
                c += 1
                s += b_tmp
    loop_length, loop_sum = get_loop_length(a)
    # 2. ループに入るまでをシミュレーション、計算、シミュレーション
    ans = 0
    b = x
    # ループまで
    while b != a:
        ans += b
        b = (b**2)%m
        n -= 1
    # ループ中
    ans += loop_sum*(n//loop_length)
    n = n % loop_length
    b = a
    for i in range(n):
        ans += b
        b = (b**2)%m
    print(ans)


Measured memory_bytes: 66436
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);



	public static void main(String[] args) {

		while (sc.hasNext()) {

			String str = sc.next();
			String[] st = str.split(",");
			double[] num = new double[st.length];

			for (int i = 0; i < st.length; i++) {
				num[i] = Double.parseDouble(st[i]);
			}

			int a = (int) num[0];
			double b = num[1];
			double c = num[2];

			if (b / (c * c) >= 25) {
				System.out.println(a);
			}

		}

	}

}

Measured memory_bytes: 26208
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int N=4000010;
int i,j,k,n,m,x,y,t,ans;
int f[N],inv[N];
int mi(int x,int y){
	if (y==0)return 1;
	int t=mi(x,y>>1);t=1ll*t*t%mod;
	return y&1?(1ll*x*t%mod):t;
}
int C(int x,int y){return 1ll*f[x]*inv[y]%mod*inv[x-y]%mod;}
int main(){
	scanf("%d%d",&n,&m);
	f[0]=1;for (i=1;i<=4000000;i++)f[i]=1ll*i*f[i-1]%mod;
	inv[4000000]=mi(f[4000000],mod-2);for (i=3999999;i>=0;i--)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	for (k=0;k<=min(n,m);k++)
		if ((3*m-k)%2==0){
			int w=(3*m-k)/2;
			ans=(ans+1ll*C(w+n-1,n-1)*C(n,k)%mod)%mod;
			if (w>=m){
				ans=(ans+mod-1ll*n*C(w-m+n-1,n-1)%mod*C(n,k)%mod)%mod;
				ans=(ans+1ll*n*C(w-m+n-2,n-2)%mod*C(n-1,k)%mod)%mod;
			}
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 31616
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	trees := make([]Tree, n)
	depth := make([]int, n)
	for i := 0; i < n; i++ {
		trees[i].parent = -1
		trees[i].left = -1
		trees[i].right = -1
	}
	for i := 0; i < n; i++ {
		id := getNextInt(scanner)
		k := getNextInt(scanner)
		l := -1
		for ii := 0; ii < k; ii++ {
			c := getNextInt(scanner)
			trees[c].parent = id
			if ii == 0 {
				trees[id].left = c
			} else {
				trees[l].right = c
			}
			l = c
		}
	}
	for i := 0; i < n; i++ {
		if trees[i].parent == -1 {
			setDepth(trees, depth, i, 0)
			break
		}
	}

	buf := make([]string, n)

	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, fmt.Sprintf("node %d: parent = %d, depth = %d, %s, [%s]", i, trees[i].parent, depth[i], getType(trees[i]), getChildren(trees, i, buf)))
	}

	writer.Flush()
}

func setDepth(trees []Tree, depth []int, i, p int) {
	depth[i] = p
	if trees[i].right != -1 {
		setDepth(trees, depth, trees[i].right, p)
	}
	if trees[i].left != -1 {
		setDepth(trees, depth, trees[i].left, p+1)
	}
}

func getType(tree Tree) string {
	if tree.parent == -1 {
		return "root"
	}
	if tree.left == -1 {
		return "leaf"
	}
	return "internal node"
}

func getChildren(trees []Tree, i int, buf []string) string {
	end := 0
	for c := trees[i].left; c != -1; c = trees[c].right {
		buf[end] = fmt.Sprintf("%d", c)
		end++
	}
	return strings.Join(buf[0:end], ", ")
}

type Tree struct {
	parent int
	left   int
	right  int
}



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

int main()
{
  int N, K, x, ans = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++)
  {
    cin >> x;
    if (K - x > x)
    {
      ans += x * 2;
    }
    else
    {
      ans += (K - x) * 2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, m, u, v, d[100005] = {};
    vector<int> g[100005] = {};
    cin >> n >> m;
    fr(m) cin >> u >> v, d[u]++, d[v]++, g[u].push_back(v), g[v].push_back(u);
    sort(d + 1, d + n + 1); reverse(d + 1, d + n + 1);
    fr1(n) if (d[i] & 1) {cout << "No"; return 0;}
    if (d[1] >= 6) cout << "Yes";
    else if (d[3] == 4) cout << "Yes";
    else if (d[2] == 2) cout << "No";
    else {
        int x = 0, y = 0;
        fr1(n) if (g[i].size() == 4) {
            if (!x) x = i;
            else y = i;
        }
        bool b[100005] = {};
        b[x] = 1;
        int w = 0;
        fr(4) {
            int c = g[x][i];
            while (1) {
                if (c == y) {
                    w++;
                    break;
                }
                if (c == x) break;
                b[c] = 1;
                if (!b[g[c][0]]) c = g[c][0];
                else if (!b[g[c][1]]) c = g[c][1];
                else break;
            }
        }
        if (w == 4) cout << "No";
        else cout << "Yes";
    }
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  string n;
  cin >> n;
  int s = n.size() - 1;
  if (n[s] == '2' || n[s] == '4' || n[s] == '5' || n[s] == '7' || n[s] == '9')
    print("hon");
  else if (n[s] == '0' || n[s] == '1' || n[s] == '6' || n[s] == '8')
    print("pon");
  else
    print("bon");
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}


// end of Template
bool nine = false;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n; cin>>n;
    while(n>0){
        if(n%10==9)nine=true;
        n/=10;
    }
    if(nine)cout<<"Yes\n";
    else cout<<"No\n";

}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , ans = INF , ps[MAXN];

int main() {
    fast_io;

    cin >> n;
    for(ll i = 0 ; i < n ; i++) cin >> ps[i];
    partial_sum(ps , ps + MAXN , ps);

    for(ll i = 0 ; i < n ; i++){
        ans = min(ans , abs(ps[n] - ps[i] * 2));
    }
    cout << ans << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int valid=n/2 + 1;
    double ans=0;
    double p[n+1];
    for(int i=1;i<=n;i++)
        cin>>p[i];
    double dp[n+1][n+1];
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        dp[0][i]=0;
        dp[i][0]= (1-p[i]) * dp[i-1][0];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            dp[i][j] = p[i] * dp[i-1][j-1] + (1-p[i]) * dp[i-1][j];
    }
    for(int i=valid;i<=n;i++)
        ans+=dp[n][i];
    cout<<setprecision(10)<<ans<<endl;
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  string s;
  cin >> s;

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

  if (s[0] == s[1]) {
    if (s[1] != s[2]) {
      if (s[2] == s[3]) {
        COUT("Yes");
        return;
      }
    }           
  }
  COUT("No");

}

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

/*

3 2
*/


Measured memory_bytes: 3616
import java.util.Scanner;

class Main{
  private static int H,W;

  public static void main(String[] args){
    
    Scanner s= new Scanner(System.in);
   
   while(true){
   H=s.nextInt();
   W=s.nextInt();
   
   if(H==0&&W==0){
       break;
   }
   for(int i = 0;i<H;i++){
       
       for(int x=0;x<W;x++){
           
          if(i==0||i==H-1){
               System.out.print("#");
           }else
           
           {if(x==0||x==W-1){
               System.out.print("#");
               
       }else{
            System.out.print(".");
       }
           }
       }
       System.out.println("");
       
   }System.out.println("");
   
  }
  }   
  
  }


Measured memory_bytes: 32788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] c = new int[3][3];
		for(int i = 0 ; i < 3 ; i++) {
			for(int j = 0 ; j < 3 ; j++) {
				c[i][j] = sc.nextInt();
			}
		}
		for(int i = 0 ; i <= 100 ; i++) {
			int[] a = new int[3];
			int[] b = new int[3];
			for(int j = 0 ; j < 3 ; j++) a[j] = c[j][0] - i;
			for(int j = 0 ; j < 3 ; j++) b[j] = c[0][j] - a[0];
			boolean ok = true;
			for(int j = 0 ; j < 3 ; j++) {
				for(int k = 0 ; k < 3 ; k++) {
					if(c[j][k] != a[j] + b[k]) ok = false;
				}
			}
			if(ok) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21972
sub f{my($u,$p,$d)=@_;$_-$p&&($d^=1+f($_,$u))for@$u;$d}<>;map{push@$_,$_[--$|]for@_=glob}<>;print f(1)?Alice:Bob

####################################
####################################
####################################
####################################
####################################
####################################
####################################
####################################
####################################
####################################

Measured memory_bytes: 170752
#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n,a;
    cin>>n;
    int arr[n];
    for (int j = 0; j < n; ++j) {
        arr[j]=0;
    }
    for (int i = 0; i < n-1; ++i) {
        cin>>a;
        arr[(a-1)]++;
    }
    for (int k = 0; k < n; ++k) {
        printf("%d\n",arr[k]);
    }
    return 0;
}


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

string s, rs;
int n, k;
vector<vector<vector<int>>> dp;

int solve();

int main() {
  cin >> s >> k;
  n = s.size();
  rs = s;
  reverse(rs.begin(), rs.end());
  cout << solve() << endl;
  return 0;
}

int solve() {
  int res = 0;
  dp.assign(n + 1, vector(n + 1, vector<int>(k + 1, 0)));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      for (int l = 0; l <= k; ++l) {
        dp[i + 1][j + 1][l] = max(dp[i + 1][j][l], dp[i][j + 1][l]);
        if (s[i] == rs[j])
          dp[i + 1][j + 1][l] = max(dp[i + 1][j + 1][l], dp[i][j][l] + 1);
        else if (l != 0)
          dp[i + 1][j + 1][l] = max(dp[i + 1][j + 1][l], dp[i][j][l - 1] + 1);
        else
          dp[i + 1][j + 1][l] = max(dp[i + 1][j + 1][l], dp[i][j][l]);
      }
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j)
      for (int l = 1; l <= k; ++l)
        dp[i][j][l] = max(dp[i][j][l], dp[i][j][l - 1]);
  for (int i = 0; i <= n; ++i) {
    // even
    res = max(res, dp[i][n - i][k] * 2);
    // odd
    if (i > 0) res = max(res, dp[i - 1][n - i][k] * 2 + 1);
  }
  return res;
}

Measured memory_bytes: 113252
import sys
import math

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def main():
	L = int(input())
	#b , c = tin()
	#s = input()
	v = int(math.log2(L))
	#pa(v)
	num_p = v
	path_info=[]
	for i in range(v):
		path_info.append([i,i+1,0])
		path_info.append([i,i+1,2**i])
	
	#for li in path_info:
	#	print(*li)
	
	nokori = L - (2 ** v)
	
	#print(nokori)
	for i in range(v+1):
		m = v - i
		if 2 ** m <= nokori:
			path_info.append([m, v, L - nokori])
			nokori -= 2 ** m
	print(v+1, len(path_info))
	for l in path_info:
		f,t,w = l
		print(*[f+1, t+1, w])
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3188
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,a[8][900],b[8][900];
int main(){
	scanf("%d",&n);
	for(int j=0;j<=120;j++)
		b[0][j]=0;
	b[1][0]=b[2][0]=b[3][0]=0;
	for(int i=1;i<=2;i++){
		for(int j=1;j<=n;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(int j=1;j<=n;j++){
		b[1][j]=b[1][j-1]+a[1][j];
	}
	for(int j=1;j<=n;j++){
		b[2][j]=max(b[1][j],b[2][j-1])+a[2][j];
	}
	printf("%d",b[2][n]);
}

Measured memory_bytes: 128
l=input().split()

w=int(l[0])
h=int(l[1])
x=int(l[2])
y=int(l[3])
r=int(l[4])

jg = 1

if 0>(x-r) or (x+r)>w:
    jg=0

if 0>(y-r) or (y+r)>h:
    jg=0
    
if jg == 1:
    print("Yes")

else :
    print("No")


Measured memory_bytes: 5596
#include<cstdio>
int main()
{
	long long sum = 0;
	int n;
	int a[120];
	scanf("%d",&n);
	for(int i =1 ; i <= n; i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int a1,b;
		scanf("%d%d",&a1,&b);
		printf("%lld\n",sum+b-a[a1]);
	}
	
return 0;
}

Measured memory_bytes: 128
/**
 * author:    Ziel
 * created:   23.04.2020 20:19:46
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
    string s, t;
    cin >> s >> t;
    int n = sz(s), m = sz(t);
    vector<vector<int>> dp(n + 1, vector<int>(m + 1));
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (!i || !j) continue;
            if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    string res;
    for (int i = n, j = m; true;) {
        if (!i || !j) break;
        if (s[i - 1] == t[j - 1]) {
            res.pb(s[i - 1]);
            i--, j--;
        } else {
            if (dp[i - 1][j] > dp[i][j - 1]) i--;
            else j--;
        }
    }
    reverse(all(res));
    cout << res << '\n';
    
	return 0;
}

/*
	Raise your standard.
*/


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

#define ll long long
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    ll sum = 0;
    ll n;
    cin >> n;
    for(ll i = 1; i<=n; i++) {
        if(i%3 == 0 && i%5 == 0) {

        }
        else if(i%3 == 0) {

        }
        else if(i%5 == 0) {

        }
        else{
            sum += i;
        }
    }
    cout << sum ;
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a>9 || b>9) cout << -1;
  else cout << a*b;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;
V<bool> visited;
vll d;
vvll edges;

ll dfs(ll i) {
    if (visited[i]) return d[i];
    else {
        visited[i] = true;
        for (auto j: edges[i]) {
            chmax(d[i], dfs(j)+1);
        }
        return d[i];
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vvll a(n, vll(n-1));
    REP(i, n) REP(j, n-1) {cin >> a[i][j]; a[i][j]--;}
    edges.resize(1001000);
    visited.resize(1001000, false);
    d.resize(1001000, 0);
    vll h(1001000, 0);
    REP(i, n) {
        rep(j, 1, n-1) {
            ll tmpa = a[i][j], pa=a[i][j-1];
            ll tmpi=i, pi=i;
            if (tmpa > tmpi) swap(tmpa, tmpi);
            if (pa > pi) swap(pa, pi);
            edges[pi*1000+pa].push_back(tmpi*1000+tmpa);
            h[tmpi*1000+tmpa]++;
        }
    }
    stack<ll> st;
    REP(i, 1001000) if (edges[i].size() && h[i]==0) st.push(i);
    vll ans;
    while (st.size()) {
        ll i=st.top(); st.pop();
        ans.push_back(i);
        for (auto j: edges[i]) {
            h[j]--;
            if (h[j] == 0) st.push(j);
        }
    }
    if (ans.size() != n*(n-1)/2) cout << -1 << '\n';
    else {
        ll ret=0;
        REP(i, 1001000) chmax(ret, dfs(i));
        cout << ret+1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 68212
#include<iostream>
#include <string>

using namespace std;
int main(){
	int a[7];
	int b[7];
	for (int i = 0; i < 7;i++){
		cin >> a[i];
		cin >> b[i];
	}
	for (int n = 0; n<7; n++){
		cout << a[n] - b[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	r.Scan(true)
	s := r.nextString()

	s2 := make([]byte, len(s))
	for i := range s {
		s2[i] = (s[i]-byte('A')+byte(n))%26 + byte('A')
	}
	fmt.Fprintln(stdout, string(s2))
}


Measured memory_bytes: 640
def main():
  inputNumEven, inputNumOdd = map(int, input().split())
  #print(inputNumEven, inputNumOdd)
  
  if inputNumEven < 0:
    inputNumEven = 0
  if inputNumOdd > 100:
    inputNumOdd = 100
    
  result = inputNumEven*(inputNumEven-1)/2 + inputNumOdd*(inputNumOdd-1)/2
    
  
  return print(int(result))

if __name__ == '__main__':
  main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n, p;
int a[1000];
int mem[60][2];

int dp(int i, int x) {
    if(i==n) return x == p;
    if(~mem[i][x]) return mem[i][x];

    return mem[i][x] = dp(i+1, x) + dp(i+1, (x+a[i])%2);
}

signed main() {

    cin >> n >> p;
    for(int i = 0; i < n; i++) cin >> a[i];

    memset(mem,-1,sizeof(mem));

    cout << dp(0, 0) << endl;


  
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<n;i++)
int main(){
  int n,k;
  cin >> k >> n;
  int a[n];
  cin >> a[0];
  int dist=0;
  rep(i,n){
	cin>>a[i];
    dist = max(dist,a[i]-a[i-1]);
  }
  dist = max(dist,k+a[0]-a[n-1]);
  cout << k-dist << endl;
}


Measured memory_bytes: 1024
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
using namespace std;
int main()
{
   ll a,b;
   cin>>a>>b;
   if(a>=b) cout<<min(a%b,abs((a%b)-b))<<endl;
   else cout<<min(a,b-a)<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll N = s.size();
    bool is_same = (s[0] == s[N-1]);
    if(is_same){
        if(N % 2 == 0){
            print("First");
        }else{
            print("Second");
        }
    }else{
        if(N % 2 == 0){
            print("Second");
        }else{
            print("First");
        }
    }
}


Measured memory_bytes: 512
#include<stdio.h>  
#include<string.h>  
char map[105][105];  
int n,m,dx[]={0,0,-1,1},dy[]={1,-1,0,0},ans;  
void dfs(int x,int y,char ch)  
{  
    map[x][y]=0;  
    for(int i=0;i<4;++i)  
    {  
        int tx=x+dx[i],ty=y+dy[i];  
        if(tx<0||tx>=n||ty<0||ty>=m||map[tx][ty]!=ch)  
        {  
            continue;  
        }  
        dfs(tx,ty,ch);  
    }  
}  
int main()  
{  
    while(scanf("%d%d",&n,&m),n|m)  
    {  
        for(int i=0;i<n;++i)  
        {  
            scanf("%s",&map[i]);  
        }  
        ans=0;  
        for(int i=0;i<n;++i)  
        {  
            for(int j=0;j<m;++j)  
            {  
                if(map[i][j])  
                {  
                    ++ans;  
                    dfs(i,j,map[i][j]);  
                }  
            }  
        }  
        printf("%d\n",ans);  
    }  
    return 0;  
}  

Measured memory_bytes: 3044
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
      if (a[i] == 0) {
        System.out.println(0);
        return;
      }
    }

    Arrays.sort(a);

    long ans = 1;

    for (int i = n-1; i >= 0; i--) {
      if (a[i] > 1000000000000000000L/ans) {
        System.out.println(-1);
        return;
      } else {
        ans *= a[i];
      }
    }

    System.out.println(ans);

  }

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const ll INF = 1e13;

#define MAX_V 210

ll d[MAX_V][MAX_V];    //d[u][v] is cost of e(u, v)
int V;      //num of v


void warshall_floyd(){
    for(int k = 0; k < V; k++)
        for(int i = 0; i < V; i++)
            for(int j = 0; j < V; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int RN[220];
int main(){
    cin >> V;
    for(int i = 0; i < V; i++){
        for(int j = 0; j < V; j++){
            if(i == j) d[i][j] = 0;
            else d[i][j] = INF;
        }
    }

    int M, R;
    cin >> M >> R;
    REP(i,R){
        int r;
        cin >> r;
        r--;
        RN[i] = r;
    }
    REP(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        d[a][b] = c;
        d[b][a] = c;
    }

    warshall_floyd();

    sort(RN, RN+R);
    ll ans = LLONG_MAX;
    do{
        ll num = 0;
        int loc = RN[0];
        for(int i = 1; i < R; i++){
            int next = RN[i];
            num += d[loc][next];
            loc = next;
        }
        ans = min(ans, num);
    }while(next_permutation(RN, RN+R));

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


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n,A[10000];
	float a;
	int i, j, k, l = 0;

	scanf("%d", &n);

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


	for (k = 0; k < n; k++) {
		printf("%d", A[k]);
		if (k != n - 1) {
			printf(" ");
		}
		else
		{
			printf("\n");
		}
	}

	for (i = 1; i <= n - 1; i++) {
		
		a = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > a) {
			A[j + 1] = A[j];
			j--;
			A[j + 1] = a;
		}

		
		for (k = 0; k < n; k++) {
			printf("%d", A[k]);
			if (k != n - 1) {
				printf(" ");
			}
			else
			{
				printf("\n");
			}
		}
		

		
	}

	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    string S, T; cin >> S >> T;
    ll max = 0;
    REP(s, S.length()-T.length()+1) {
        ll l = 0;
        REP(t, T.length()) {
            if (T[t] == S[s+t]) l++;
            chmax(max, l);
        }
    }
    cout << T.length() - max << "\n";
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n; cin>>n;
    cout<<(1+n)*n/2<<endl;return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
	int a,b,c;
	char d;
	int t,h;
	t=h=0;
	while(cin>>a>>d>>b>>d>>c)
	{
		if(a*a+b*b==c*c)
		{
			t++;
		}
		if(a==b)
		{
			h++;
		}
	}
	cout<<t<<endl<<h<<endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <queue>
using namespace std;
int su(int x)
{
    if(x==2) return 1;
    if(x%2==0) return 0;
    for(int i=3;i*i<=x;i++)
    {
        if(x%i==0) return 0;
    }
    return 1;
}

int main()
{
    int n;
    cin>>n;
    int sum=0;
    while(n--)
    {
        int x;
        cin>>x;
        if(su(x)) sum++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3080
#include<stdio.h>
int main(){
  int A[100],N;
  int i,j,k,flag=1,temp,num=0;

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
      }


  while(flag){
    flag=0;
    for(j=N-1;j>0;--j){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	flag=1;
	num++;
      }
    }
  }

  printf("%d",A[0]);
    for(j=1;j<N;j++){
      printf(" %d",A[j]);
    }
    printf("\n");
    printf("%d\n",num);

    return 0;
    
}
      
      
      
  
  



Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FastIO ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL)

ll find_minenergy(vector < int > &v){
	int n = v.size();
	vector < ll > dp(n);
	dp[0] = 0 , dp[1] = abs(v[1] - v[0]);
	for(int i = 2;i < n;i++){
		dp[i] = min(abs(v[i] - v[i - 1]) + dp[i - 1] , abs(v[i] - v[i - 2]) + dp[i - 2]);
	}
	ll ans = dp[n - 1];
	return ans;
}

int main(){
	int n;
	cin >> n;
	vector < int > v;
	for(int i = 0;i < n;i++){
		int element;
		cin >> element;
		v.push_back(element);
	}
	ll min_energy = find_minenergy(v);
	cout << min_energy << "\n";
	return 0;
}


Measured memory_bytes: 4492
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var array = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        long A = array[0];
        long B = array[1];
        long C = array[2];
        long K = array[3];
        if (Math.Abs(A - B) > Math.Pow(10, 18)) Console.WriteLine("Unfair");
        var res = K % 2 == 0 ? A - B : B - A;
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13524
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char **argv) {
    long long N, A, B;
    cin >> N >> A >> B;

    auto AB = A + B;
    auto completeCycles = N / AB;
    auto remainder = N % AB;

    cout << (completeCycles * A + min(A, remainder)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {

	ll a, b;
	char op;
	scanf("%lld %c %lld", &a, &op, &b);
	switch(op) {
		case '+':
			cout << a + b << endl;
			break;
		case '-':
			cout << a - b << endl;
			break;
	}
    return 0;

}



Measured memory_bytes: 3640
#include<stdio.h>
int main(void)
{
	int n,m,k,i,j,w=0,s;
	char d[101][101];
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++) scanf(" %c",&d[i][j]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(d[i][j]!='#'){
				for(s=0;s<k;s++){
					if(d[i][j+s]!='.') break;
					if(s==k-1) w++;
				}
				for(s=0;s<k;s++){
					if(d[i+s][j]!='.') break;
					if(s==k-1) w++;
				}	
			}
		}
	}
	printf("%d\n",w);
	return 0;
}	

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

#define FOR(i, a, b)  for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << "\n"
#define _ << " _ " <<
#define ll long long

using namespace std;

vector <int> graf[100100];
vector <int> child[100100];
int par[100100];
int D[100100];
int F[100100];
int dis;

void dfs(int x) {
  dis++;
  D[x] = dis;
  REP(i, graf[x].size()) {
    int ne = graf[x][i];
    if (ne == par[x]) continue;
    child[x].push_back(ne);
    par[ne] = x;
    dfs(ne);
  }
  F[x] = dis;
  return;
}

int main() {
  //ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graf[a].push_back(b);
    graf[b].push_back(a);
  }
  par[0] = -1;
  dfs(0);

  int a = 0;
  int b = n - 1;

  int fl = 0;
  int oa = 0;
  int ob = 0;
  //cout << "asdas\n";
  while (par[b] != a) {
    //cout << a << " " << b << endl;
    int ne;
    REP(i, child[a].size()) {
      ne = child[a][i];
      if (F[ne] >= D[b]) break;
    }
    a = ne;
    oa++;
    fl = 1;
    if (par[b] == a) break;
    b = par[b];
    fl = 0;
    ob++;
  }
  int B = (F[b] - D[b] + 1) - ob;
  int A = n - B - ob - oa;
  if (fl == 1) B--;
  if (A > B) cout << "Fennec\n";
  else        cout << "Snuke\n";

  return 0;
}


Measured memory_bytes: 20224
S = input()
Year = S[0:4]
Month = S[5:7]
Day = S[8:10]

if int(Year) <= 2018:
    print('Heisei')
elif (int(Year) == 2019) and (int(Month) <=4):
    print('Heisei')
else:
    print('TBD')

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
	int a,b,c,count=0,i;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<b+1;i++){
		if(c%i==0){
			count++;
		}	
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 596
N, A, B, K = map(int, input().split())

MOD = 998244353
factorials = [1]
inv_facts = [1]
for i in range(1, N+1):
    factorials.append(factorials[-1] * i % MOD)
    inv_facts.append(inv_facts[-1] * pow(i, MOD-2, MOD) % MOD)

def combi(n, k):
    ret = factorials[n]
    ret *= inv_facts[k]
    ret %= MOD
    ret *= inv_facts[n-k]
    ret %= MOD
    return ret

ans = 0
for a in range(N+1):
    rest = K - (A * a)
    if rest < 0:
        break
    if rest % B == 0:
        b = rest // B
        if b <= N:
            tmp = combi(N, a) * combi(N, b) % MOD
            ans += tmp
            ans %= MOD
print(ans)



Measured memory_bytes: 118132
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B; cin>>A>>B;
    int ans=0;
    for(int i=A;i<=B;i++){
        string s=to_string(i),t=s;
        reverse(ALL(t));
        if(s==t) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256