akhauriyash/Code-Regression huggingface dataset:
import javax.swing.text.html.HTMLDocument;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.*;

class Main {
    public static void main(String[] args){
        try {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            long t=Long.parseLong(br.readLine());
            long sum=100,c=0;
            while(sum<t){
                sum=sum+(sum/100);
                c++;
            }
            System.out.println(c);

        } catch (Exception e) {
            System.out.println("kkkk "+ e.getMessage());
        }
    }
    static int modInverse(int x,int m){
        return power(x,m-2,m);
    }
    static int power(int x, int y, int m)
    {
        if (y == 0)
            return 1;

        long p = power(x, y / 2, m) % m;
        p = (p * p) % m;

        return (int)((y%2==0)? p : (x*p)%m);
    }
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
}

Measured memory_bytes: 32504
// B - Uneven Numbers

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

int count_digit(int a) {
	int digit = 0;
	while (a > 0) {
		a /= 10;
		digit++;
	}

	return digit;
}

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

	int ans = 0;
	for (int i=1; i<=N; i++) {
		if (count_digit(i) % 2 == 1) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;

  VI xs(N);
  REP(i,N) cin >> xs[i];
  SORT(xs);

  int ans = 0;
  REP(i,N-1) ans += xs[i+1] - xs[i];
  cout << ans << endl;

  return 0;
}


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

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

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

   int dp[n];	
   dp[0] = 0;
   dp[1] = abs(h[0] - h[1]);
   
   for(int i=2;i<n;i++)
   	  dp[i] = min( dp[i-1] + abs(h[i] - h[i-1]),
   	               dp[i-2] + abs(h[i]-h[i-2]));
   
   cout<<dp[n-1];


return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll a,b,c,d,e,f,g,h,i;
  cin>>a>>b>>c
     >>d>>e>>f
    >>g>>h>>i;
  if(c-b==f-e && f-e==i-h && b-a==e-d && e-d==h-g) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string ans;
bool checker(ll N, ll K) {
    ll now = 1;
    for(int i = 3; i < K; i++) {
        now *= 2;
        if(now >= N) {
            return true;
        }
    }
    return false;
}

void f(int i, string S, int K, int len) {
    string T = S;
    int N = S.size();
    reverse(T.begin(), T.end());
    S += T;
    /*
    if(len == 0 && K == 1) {
        string ret = S.substr(i, N);
        cerr << ret << endl;
        chmin(ans, ret);
        return;
    }
    */
    if(K == 1) {
        string ret = S.substr(max(0, N - len), N);
        cerr << "ans: " << ret << endl;
        chmin(ans, ret);
        return;
    }
    if(i != -1) {
        string ret = S.substr(2 * N - i - N, N);
        ///cerr << i << " " << len << " " << ret << endl;
        if(i + len != N) f(-1, ret, K - 1, len);
        if(i + len == N) f(-1, ret, K-1, min(N, len * 2));
        return;
    }
    //cerr << "now:" << S << endl;
    string ret = S.substr(min(len, N), N);
        cerr << ret << endl;
    f(-1, ret, K - 1, min(N, len * 2));
}

string solve(int N, int K, string S) {
    if(K == 0) return S;
    string ans = "z";
    ans[0]++;
    string T = S;
    reverse(T.begin(), T.end());
    S += T;
    for(int i = 0; i <= N; i++) {
        string tmp = S.substr(i, N);
        string ret = solve(N, K - 1, tmp);
        chmin(ans, ret);
    }
    return ans;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> K >> S;
    if(K <= 1) {
        cout << solve(N, K, S) << endl;
        return 0;
    }
    if(checker(N, K)) {
        char mini = 'z';
        for(int i = 0; i < S.size(); i++) {
            chmin(mini, S[i]);
        }
        for(int i = 0; i < S.size(); i++) {
            cout << mini;
        }
        cout << endl;
        return 0;
    }
    char mini = 'z';
    for(int i = 0; i < S.size(); i++) {
        chmin(mini, S[i]);
    }
    ans = "z";
    ans[0]++;
    //cerr << ans << endl;
    /*
    for(int i = 0; i < S.size(); i++) {
        cerr << "----" << i << "----" << endl;
        f(i, S, K, 0);
    }
    */
    int l = 0;
    for(int r = 0; r < S.size(); r++) {
        if(S[r] == mini) continue;
        if(l != r) {
            cerr << l << " " << r << endl;
            f(l, S, K, r - l);
        }
        l = r + 1;
    }
    if(l != S.size()) {
        cerr << l << " " << S.size() - l << endl;
        f(l, S, K, S.size() - l);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H==0 and W==0) break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(j==0 or j==W-1 or i==0 or i==H-1){
                    cout << "#";
                }
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
n = int(input())
S = []
for _ in range(n):
    S.append(input())

d = {}
for s in S:
  if s in d:
    d[s] += 1
  else:
    d[s] = 1

list = []
max = max(d.values())
for k, v in d.items():
  if max == v:
    list.append(k)

list.sort()
for str in list:
  print(str)

Measured memory_bytes: 35220
#include <iostream>
#include <algorithm>
#include <cmath>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define FORE(i,a,b) for (int i=(int)(a);i<=(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FOR(i,0,n)

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

int main() {
  int N; cin >> N;
  
  int pre_num; cin >> pre_num; pre_num--;
  REP(i,N-1) {
    int h; cin >> h;
    if (pre_num < h) {
      pre_num = h-1;
    } else if (h < pre_num) {
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>
#include<string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <map>
#include <cstring>
using namespace std;
int main() {
    int n,now=1;
    cin>>n;
    if(n==7){
        printf("1\n");
        return 0;
    }
    else if(n%7==0) n/=7;
    for(int i=1;i<=10000000;i++)
    {
        if(now%n==0){
            printf("%d\n",i);
            return 0;
        }
        now=now*10+1;
        now%=n;
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;

int main(){
    int n; cin >> n;
    map<ll,ll> m;
    rep(i,n){
        ll a;
        cin >> a;
        if(m.count(a)){
            m.erase(a);
        }else{
            m[a] = 1;
        }
    }

    cout << m.size() << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

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

  ll cnt = 1;
  for(ll i = 0; i < 5e07; i++){
    if(a * i % b == c){
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}


Measured memory_bytes: 256
//Tap Dance
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main()
{
    string S;
    cin >> S;
    bool flag = true;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 1) {
            if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {
                continue;
            }
            else {
                flag = false;
            }
        }
        else {
            if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {
                continue;
            }
            else {
                flag = false;
            }
        }
    }
    if (flag) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 888
# include <cstdio>
# include <cstring>
using namespace std;

int main()
{
	char a[100];
	char b[100];
	scanf("%s",a);
	int len = strlen(a);
	int k = 0;
	for(int i = 0;i < len;i++)
	{
		if(a[i] == 'B')
		{
			if(k > 0) 
				k--;
		}
		else
		{
			b[k] = a[i];
			++k;
		}
	}
	b[k] = '\0'; 
	printf("%s\n",b);
	return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var N string
	fmt.Scan(&N)

	n, _ := strconv.Atoi(N)

	var sum int
	for _, nn := range strings.Split(N, "") {
		num, _ := strconv.Atoi(nn)
		sum += num
	}

	if n%sum == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12);
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}
//priority_queue<int, vector<int>, greater<int> > que; //昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED
    vi abc(3);
    rep(i,3)cin >> abc[i];
    SORT(abc);
    cout << abc[2]*10+abc[1]+abc[0] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
long long f[60][2],a[60];
int main()
{
    long long  n,a,b,c,d,i,j,l1,l2,r1,r2;
    cin>>n>>a>>b>>c>>d;
    n--;
    for (i=0;i<=n;i++)
    {
        r1=d*i-(n-i)*c;
        l1=c*i-(n-i)*d;
        if (a+l1<=b&&a+r1>=b)
        {
            cout<<"YES"<<endl;
            break;
        }
    }
    if (i==n+1) cout<<"NO"<<endl;

}


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

int main() {
  int N, min;
  cin >> N;
  min = N % 10;
  if(min == 3) cout << "bon" << endl;
  else if(min == 0 or min == 1 or min == 6 or min == 8)
    cout << "pon" << endl;
  else cout << "hon" << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#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>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
const int MAXN=2e5+5;
int a[MAXN];
ll tot=0;
int main()
{
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {
    scanf("%d",&a[i]);
    tot+=a[i];
  }
  ll ans=0x3f3f3f3f3f3f3f3f;
  ll now=0,els;
  for(int i=1;i<n;i++)
  {
    now+=a[i];
    els=tot-now;
    ans=min(ans,abs(els-now));
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    vector<int> a;
    vector<int> b;
    int count_1 = 0, count_2 = 0, count_3 = 0, count_4 = 0;

    for(int i = 0; i < 3; i++){
        int c, d;
        cin >> c >> d;
        switch(c){
            case 1:
                count_1++;
                break;
            case 2:
                count_2++;
                break;
            case 3:
                count_3++;
                break;
            case 4:
                count_4++;
                break;
        }

        switch(d){
            case 1:
                count_1++;
                break;
            case 2:
                count_2++;
                break;
            case 3:
                count_3++;
                break;
            case 4:
                count_4++;
                break;
        }
        a.push_back(c);
        a.push_back(d);
    }

    if(count_1 >= 3 || count_2 >= 3 || count_3 >= 3 || count_4 >= 3){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char s[51];
    int n,i,count=0;
    scanf("%d %s",&n,s);
    for(i=0;i<n;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 1708
#include <cstdio>  
#include <stack>  
#include <queue>
#include <cmath>  
#include <vector>  
#include <cstring>  
#include<set>
#include<map>
#include<ctime>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef unsigned long long uLL;
const int M = 1005;
const int N = 1000005;
const int mod = 1000000007;
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const LL lINF = 0x3f3f3f3f3f3f3f3fLL;
const int sINF = 0xcfcfcfcf;
#define ls (rt<<1)
#define rs (rt<<1|1)
char s[100];
int len,flag1,flag2,flag3;
int main()
{
	while (~scanf("%s", s))
	{
		flag3=flag1 = flag2 = 0;
		if (s[0] == 'A')
			flag1 = 1;
		len = strlen(s);
		for (int i = 2; i < len - 1; i++)
		{
			if (s[i] == 'C')
			{
				flag2 ++;
			}
		}
		for (int i = 0; i < len; i++)
		{
			if ((s[i] != 'A'&&s[i] != 'C') && (s[i]<'a' || s[i]>'z'))
				flag3 = 1;
		}
		if (flag1&&(flag2==1)&&!flag3)
			printf("AC\n");
		else
			printf("WA\n");
	}
}

Measured memory_bytes: 256
// ３つの整数を読み込み、それらを値が小さい順に並べて出力するプログラムを作成して下さい。
// 【入力】
// ３つの整数が空白で区切られて与えられます。
// 【出力】
// 小さい順に並べ替えた３つの整数を１行に出力して下さい。
// 整数の間に１つの空白を入れて下さい。
// 【制約】
// 1 ≤ ３つの整数 ≤ 10,000
// 【例】
// 入力：3 8 1、出力：1 3 8
#include<stdio.h>

int main( void) {
  int a, b, c;
  int swapVal;

  scanf( "%d %d %d", &a, &b, &c);

  if ( a > b) {
    swapVal = a;
    a = b;
    b = swapVal;
  }

  if ( a > c) {
    swapVal = a;
    a = c;
    c = swapVal;
  }

  if ( b > c) {
    swapVal = b;
    b = c;
    c = swapVal;
  }

  printf( "%d %d %d\n", a, b, c);

  return 0;
}



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

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

	int n, k; cin >> n >> k;
	vector<int> candles(n);
	for(int i = 0; i < n ;i++) cin >> candles[i];
	int dist = (int)1e9;
	int i = 0;
	while(i + k - 1 < n){
		int mindist = min(abs(candles[i]), abs(candles[i + k - 1]));
		dist = min(dist, mindist + abs(candles[i] - candles[i + k -1]));
		i++;
	}
	cout << dist << endl;
	return 0;	
}





  


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

int calc_digit(int a){
  int i = 0;
  
  while(true){
    a = a / 10;
    i++;
    if(a == 0){
      break;
    }
  }
  return i;
}


int main() {
  long long n; cin >> n;
  int ans = 10;
  
  for(int a = 1; a <= sqrt(n); a++){
    if(n % a == 0){
      long long b = n / a;
    
      ans = min(ans, max(calc_digit(a), calc_digit(b)));
    }
    
  }
  
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;

ll N, M, P, Q, R, S, A, B, C, D, E, F;
ll ans[200005];

ll fact[200005], invfact[200005];

ll dp[400005], sub[400005], sub2[400005], par1[400005], par2[400005], proc[400005], prod[400005];
ll X[400005], Y[400005];
vector<pi> AdjList[200005];

const ll mod = 1000000007;

ll mod_inv(ll x){
	ll ans = 1, base = x, exp = mod - 2;
	while (exp){
		if (exp & 1) ans *= base;
		base *= base;
		base %= mod;
		ans %= mod;
		exp >>= 1;
	}
	return ans;
}

ll comp(int e){
	int p = X[e/2], v = Y[e/2];
	if (e % 2 == 1) swap(p,v);
	if (dp[e] != -1) return dp[e];
	dp[e] = 1;
	if (proc[v]){
		if (e % 2 == 1){
			sub[e] = N - sub[e-1];
			dp[e] = (((((prod[v] * fact[sub[e-1]]) % mod) * mod_inv(dp[e-1])) % mod) * fact[sub[e]-1]) % mod;
		}
		else{
			sub[e] = N - sub[e+1];
			dp[e] = (((((prod[v] * fact[sub[e+1]]) % mod) * mod_inv(dp[e+1])) % mod) * fact[sub[e]-1]) % mod;
		}
	}
	else{
		int n = 0;
		for (auto it : AdjList[v]){
			if (dp[it.second] != -1) n++;
			if (it.first == p) continue;
			comp(it.second);
			dp[e] *= dp[it.second];
			dp[e] %= mod;
			dp[e] *= invfact[sub[it.second]];
			dp[e] %= mod;
			sub[e] += sub[it.second];
		}
		dp[e] *= fact[sub[e]];
		dp[e] %= mod;
		sub[e]++;

		if (n == AdjList[v].size()){
			proc[v] = 1;
			prod[v] = 1;
			for (auto it : AdjList[v]){
				prod[v] *= invfact[sub[it.second]];
				prod[v] %= mod;
				prod[v] *= dp[it.second];
				prod[v] %= mod;
			}
		}
	}
	return dp[e];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	fact[0] = 1;
	invfact[0] = 1;
	for (ll i = 1; i <= N; ++i){
		fact[i] = fact[i-1] * i;
		fact[i] %= mod;
		invfact[i] = mod_inv(fact[i]);
	}
	for (ll i = 1; i <= 2*N; ++i){
		dp[i] = -1;
	}
	for (int i = 1; i < N; ++i){
		cin >> A >> B;
		AdjList[A].push_back(pi(B,2*i));
		AdjList[B].push_back(pi(A,2*i+1));
		X[i] = A;
		Y[i] = B;
	}
	for (int i = 1; i <= N; ++i){
		ll ans = 1;
		ans *= fact[N-1];
		ans %= mod;
		for (auto it : AdjList[i]){
			comp(it.second);
			ans *= invfact[sub[it.second]];
			ans %= mod;
			ans *= dp[it.second];
			ans %= mod;
		}
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 41728
// https://atcoder.jp/contests/abc099/tasks/abc099_c

#include "algorithm"
#include "iostream"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

void solve() {
  ll N;
  cin >> N;

  ll dp[N + 1];  // dp[i]: i 円払う時の最小コスト
  for (int i = 1; i <= N; i++) dp[i] = 1ll << 60;
  dp[0] = 0;

  for (int i = 1; i <= N; i++) {
    dp[i] = min(dp[i], dp[i - 1] + 1);

    for (int j = 6; i - j >= 0; j *= 6) {
      dp[i] = min(dp[i], dp[i - j] + 1);
    }

    for (int j = 9; i - j >= 0; j *= 9) {
      dp[i] = min(dp[i], dp[i - j] + 1);
    }
  }

  cout << dp[N] << endl;
}

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
#endif


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    ll s; cin >> s;
    int x1 = 0, y1 = 0;
    int x2, y2, x3, y3;
    if (s > 1e9) {
        y3 = 1e9;
        x2 = (s+y3-1)/y3;
        x3 = (ll)x2*y3 - s;
        y2 = 1;
    } else {
        y3 = s;
        x2 = 1;
        y2 = 0;
        x3 = 0;
    }
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " ";
    cout << x3 << " " << y3 << endl;
}

Measured memory_bytes: 3600
# -*- coding:utf-8 -*-

l = list(map(int, input().split()))
a = [0]
a.extend(list(map(int, input().split())))

num = 0
f = True
while(f):
    f = False
    for i in range(l[0]):
        if(((a[i] + a[i+1]) > l[1])):
            f = True
            sub = (a[i] + a[i+1]) - l[1]
            a[i+1] -= sub
            num += sub
print(num)


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

using namespace std;

struct edge {
    int to;
    int cost;
    edge(int a, int b) : to(a), cost(b) {}
};

vector<vector<edge>> e;
int N;

pair<int, int> dfs(int p, int par = -1)
{
    pair<int, int> res = make_pair(0, p);
    for (auto x : e[p]) {
        if (x.to == par) continue;
        auto t = dfs(x.to, p);
        if (t.first + x.cost > res.first) {
            res.first = t.first + x.cost;
            res.second = t.second;
        }
    }
    return res;
}

int main()
{
    cin >> N;
    e.resize(N);
    for (int i = 0; i < N-1; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        e[s].emplace_back(t, w);
        e[t].emplace_back(s, w);
    }
    auto res = dfs(0);
    res = dfs(res.second);
    cout << res.first << endl;
}


Measured memory_bytes: 15924
#include<bits/stdc++.h>
using namespace std;
int main(){
	char S[7];
	scanf("%s", S);
	int cnt = 0;
	for(int i = 0; i < 6; i++){
		if(S[i] == '1') cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 256
N,x=map(int,input().split())
A=list(map(int,input().split()))
ans=0
if A[0]>x:
  ans+=A[0]-x
  A[0]-=ans
  
for i in range(1,len(A)):
  if A[i-1]+A[i]<=x:
    continue
  diff=(A[i-1]+A[i])-x
  ans+=diff
  A[i]-=diff

print(ans)


Measured memory_bytes: 14052
#import"cstdio"
long n,m;
void d(long a,int f){if(a<=n)m+=f==7,a*=10,d(a+3,f|1),d(a+5,f|2),d(a+7,f|4);}
main(){scanf("%ld",&n);d(0,0);printf("%ld",m);}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#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 RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define M_PI 3.14159265358979323846
template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
	while (*sdbg != ',')cerr << *sdbg++; cerr << '=' << h << ','; _dbg(sdbg + 1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
	os << "["; for (auto& vv : V) os << vv << ","; os << "]";
	return os;
}

template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.st << "," << P.nd << ")";
}


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif
const int mx = (int)1e6;

int32_t main(int32_t argc, char ** argv) {
	ios_base::sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	map<int, int> num;
	REP(i, n) {
		int t;
		cin >> t;
		num[t]++;
	}
	vector<PII> dupsko;
	for (PII p : num) {
		swap(p.first, p.second);
		dupsko.push_back(p);
	}
	sort(ALL(dupsko), greater<PII>());
	int res = 0;
	while (dupsko.size() > k) {
		res += dupsko.back().first;
		dupsko.pop_back();
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 17648
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
    char ch;
    int count[26]= {};
    while(cin >> ch){
        ch = tolower(ch);
        if(isalpha(ch)){
            count[ch-'a']++;
        }
    }
    for(int i=0;i<26;i++){
        printf("%c : %d\n",i+'a',count[i]);
    }
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    rep(ki, k){
        vector<int> b(n + 1);
        rep(i, n){
            int l = max(0, i - a[i]);
            int r = min(i + a[i] + 1, n);
            b[l]++;
            b[r]--;
        }
        rep(i,n) b[i + 1] += b[i];
        b.pop_back();
        if(a == b) break;
        a = b;
    }
    rep(i,n) cout << a[i] << endl;
    return 0;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
using namespace std;
    
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
    
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
    
class fact {
public:
    int fmod = 1e9+7;
    vector<int> fac, inv;
    fact (int n, int Mod = 1e9+7) {
        fmod = Mod;
        fac = vector<int>(n,0);
        inv = vector<int>(n,0);
        fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
        for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
    }
    ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
    ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
    
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
int poorpow(int b, int a) {
    int tmp = 1;
    REP (i,a) {
        tmp *= b;
    }
    return tmp;
}


bool solve() {
    int n,k; cin >> n >> k;
    if (n % k == 0) cout << 0 << endl;
    else cout << 1 << endl;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();    
}


Measured memory_bytes: 256
N,K = gets.split.map(&:to_i)
ps = gets.split.map(&:to_f)


es = ps.map {|pv| 1 + 0.5*(pv-1)}
ret = curr = es[0..K-1].inject(&:+)
i = K
while i < N
  curr = curr - es[i-K] + es[i]
  ret = curr if ret < curr
  i+=1
end

p ret


Measured memory_bytes: 16524
#include <stdio.h>

int main(){

int a,b,n,m;

while(1){

scanf("%d %d",&a,&b);

if(a==0&&b==0)

break;

for(n=1;n<=a;n++){

	if(n==1||n==a){

		for(m=1;m<=b;m++){

			printf("#");

		}

	}else{

		printf("#");

		for(m=2;m<=b-1;m++){

			printf(".");

		}

		printf("#");

	}

printf("\n");

}

printf("\n");

}

return 0;

}

Measured memory_bytes: 572
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N,M;
char BLUE[100][11],RED[100][11];
bool used[100];

bool strCmp(char* base, char* comp){
	int length1,length2;
	for(length1=0;base[length1] != '\0';length1++);
	for(length2=0;comp[length2] != '\0';length2++);
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

int main(){

	scanf("%d",&N);

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

		scanf("%s",BLUE[i]);
	}

	scanf("%d",&M);

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

		scanf("%s",RED[i]);
	}

	int ans = 0,tmp;

	//青に存在する文字列のみ考える
	for(int i = 0; i < N; i++){

		used[i] = false;
	}

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

		if(used[i])continue;

		used[i] = true;

		tmp = 1;

		//青を調べる(自分以前には、同じものはない)
		for(int k = i+1; k < N; k++){
			if(strCmp(BLUE[i],BLUE[k])){
				used[k] = true;
				tmp++;
			}
		}

		//赤を調べる
		for(int k = 0; k < M; k++){
			if(strCmp(BLUE[i],RED[k])){

				tmp--;
			}
		}

		ans = max(ans,tmp);
	}

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

	return 0;
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int n;
  cin >> n;
  ll a[n];
  ll s = n * 1ll *(n + 1) / 2ll;
  ll total = 0;
  for(int i = 0 ; i < n ; i ++ ){
    cin >> a[i];
    total += a[i];
  }
  if(total % s != 0){
    cout << "NO\n";
    return 0;
  }
  if(n == 1){
    cout << "YES\n";
    return 0;
  }
  total /= s;
  ll cur = 0;
  ll x;
  for(int i = 0; i < n ; i ++ ){
    x = a[(i - 1 + n) % n] - a[i];
    x += total;
    if(x < 0){
      cout << "NO\n";
      return 0;
    }
    if(x % n != 0){
      cout << "NO\n";
      return 0;
    }
    cur += x/n;
  }
  if(cur == total)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int n = S.size();
    int now = 0;
    int ans = n;
    for (int i = 0; i < n; i++) {
        if (S[i] == 'S') now++;
        else {
            if (now) {
                now -= 1;
                ans -= 2;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

bool solve(vector<int> datos) {
	bool comodin = 1;
	for (int i = 0; i < datos.size() && comodin; i++) {
		if (datos[i] != i+1) {
			for (int j = i+1; j < datos.size(); j++) {
				if (datos[j] == i + 1) {
					swap(datos[i], datos[j]);
					comodin = 0;
				}
			}
		}
	}
	for (int i = 0; i < datos.size(); i++)
		if (datos[i] != i+1) return 0;
	return 1;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> datos(n);
	for (int &i : datos) cin >> i;
	cout << (solve(datos) ? "YES\n" : "NO\n");
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int dig(int n) {
	
	int ans = 0;
	while(n > 0) {
		ans++;
		n /= 10;
	}

	return ans;
}

int main() {

	int a, b;

	while (cin>>a>>b) {

		int n = a + b;

		cout << dig(n) << endl;
	}
	return 0;
}




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



int main() {

  int64_t n;
  cin>>n;

  //全ての組み合わせ　10^n
  int64_t out_10 = 1;
  for(int i=0;i<n;i++){
    out_10*=10;
    out_10%=1000000007;
  }

  //1を含まない組み合わせ( 9を含まない組み合わせ　)　9^n
  int64_t out_9=1;
  for(int i=0;i<n;i++){
    out_9*=9;
    out_9%=1000000007;
  }

  //1も9も含まない組み合わせ 8^n
  int64_t out_8=1;
  for(int i=0;i<n;i++){
    out_8*=8;
    out_8%=1000000007;
  }

  int64_t out_wk =  (( out_10 - out_9 - out_9 + out_8 )%1000000007);
  if(out_wk<0)
    cout<<(out_wk+1000000007)<<endl;
  else
    cout<<out_wk<<endl;
  return 0;
}

Measured memory_bytes: 3624
def main():
    n = int(input())
    x = list(map(int, input().split()))
    
    ans_tmp = 10000000000000
    for j in range(100):
        ans = 0
        for i in x:
            ans += (i-(j+1))**2

        if ans_tmp >= ans:
            ans_tmp = ans
    
    print(ans_tmp)

if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
import numpy as np
N = int(input())
A = np.array([0] + [int(x) for x in input().split()] + [0])
total = np.abs(np.diff(A)).sum()
saved = np.abs(A[1:-1] - A[:-2]) + np.abs(A[1:-1] - A[2:]) - np.abs(A[:-2] - A[2:])
answer = total - saved
print(*answer, sep='\n')


Measured memory_bytes: 22972
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;
  int M;
  int X;
  int Y;
  int num = -1e7;
  int num2 = 1e7;
  
  cin >> N >> M >> X >> Y;
  
  vector<int> x(N);
  vector<int> y(M);
  
  for(int i = 0;i < N;++i){
    cin >> x[i];
  }
  
  for(int i = 0;i < M;++i){
    cin >> y[i];
  }
  
  for(int i = 0;i < N;++i){
    num = max(num,x[i]);
  }
  
  for(int i = 0;i < M;++i){
    num2 = min(num2,y[i]);
  }
  
  for(int i = 0;i < M;++i){
    if(X < y[i] && y[i] <= Y && num < y[i] && num2 >= y[i]){
      cout << "No War" << endl;
      return 0;
    }
  }
  
  cout << "War" << endl;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

const LL mod = 1e9 + 7;

int main() {
  string s; cin >> s;
  int n = s.size();

  LL dp[100005][13];
  rep(i, n + 1) {
    rep(j, 13) dp[i][j] = 0;
  }
  dp[0][0] = 1;
  rep(i, n) {
    int t;
    if (s[i] == '?') t = -1;
    else t = s[i] - '0';

    rep(j, 10) {
      if (t != -1 && t != j) continue;
      rep(k, 13) {
        dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
      }
    }
    rep(j, 13) dp[i + 1][j] %= mod;
  }

  cout << dp[n][5] << endl;
}

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

namespace ABC092D
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = line[0] - 1;
            int B = line[1] - 1;

            char[,] ans = new char[100, 100];
            for(int i = 0; i < 100; i++)
            {
                for(int j = 0; j < 100; j++)
                {
                    if (j < 50)
                    {
                        ans[i, j] = '#';
                    }
                    else
                    {
                        ans[i, j] = '.';
                    }
                }
            }

            for (int i = 0; i < 50; i++)
            {
                for (int j = 0; j < 25; j++)
                {
                    if (A == 0 && B == 0) break;
                    if (A > 0)
                    {
                        ans[2 * i, 2 * j] = '.';
                        A--;
                    }
                    if (B > 0)
                    {
                        ans[2 * i, 99 - 2 * j] = '#';
                        B--;
                    }
                }
            }

            Console.WriteLine("100 100");
            for(int i = 0; i < 100; i++)
            {
                string line1 = "";
                for(int j = 0; j < 100; j++)
                {
                    line1 += ans[i, j].ToString();
                }
                Console.WriteLine(line1);
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13368
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100000
#define LL long long
using namespace std;
int n,m;struct Data
{
	int a,b,p;I bool operator < (Con Data& o) Con {return 1LL*p*a+1LL*(m-p)*b>1LL*o.p*o.a+1LL*(m-o.p)*o.b;}
}s[N+5];
class FastIO
{
	private:
		#define FS 100000
		#define tc() (A==B&&(B=(A=FI)+fread(FI,1,FS,stdin),A==B)?EOF:*A++)
		#define D isdigit(c=tc())
		char c,*A,*B,FI[FS];
	public:
		I FastIO() {A=B=FI;}Tp I void read(Ty& x) {x=0;W(!D);W(x=(x<<3)+(x<<1)+(c&15),D);}
}F;
#define V(i,v) (v<=s[i].p?1LL*v*s[i].a:1LL*s[i].p*s[i].a+1LL*(v-s[i].p)*s[i].b)
I bool Check(Con LL& w)
{
	RI i,x=w/m,y=w%m;LL t=0;for(i=1;i<=x;++i) t+=1LL*(m-s[i].p)*s[i].b;for(;i<=n;++i) t-=1LL*s[i].p*s[i].a;
	for(i=x+1;i<=n;++i) if(t+V(i,y)>=0) return 1;for(i=1;i<=x;++i) if(t+V(x+1,m)-V(i,m)+V(i,y)>=0) return 1;return 0;
}
int main()
{
	RI i;for(F.read(n),F.read(m),i=1;i<=n;++i) F.read(s[i].p),F.read(s[i].a),F.read(s[i].b);
	sort(s+1,s+n+1);LL l=0,r=1LL*n*m,mid;W(l<r) Check(mid=l+r-1>>1)?r=mid:l=mid+1;return printf("%lld\n",r),0;
}

Measured memory_bytes: 4944
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  string s;
  cin >> s;
  if (s.size() == 3) {
    reverse(s.begin(), s.end());
  }
  cout << s << endl;
  return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

int add(int a, int b) {
  return a + b - mod * (a + b >= mod);
}

int mul(int a, int b) {
  return int(1ll * a * b % mod);
}

int power(int a, int x) {
  if (x == 0) {
    return 1;
  }
  return mul(power(mul(a, a), x >> 1), (x & 1 ? a : 1));
}

int divide(int a, int b) {
  return mul(a, power(b, mod - 2));
}

int sub(int a, int b) {
  return a - b + mod * (a < b);
}

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

  int x, y;
  cin >> x >> y;
  if (x > y) {
    swap(x, y);
  }
  if ((2 * y - x) % 3) {
    cout << 0;
    return 0;
  }
  int b = (2 * y - x) / 3;
  int a = y - 2 * b;
  if (a < 0) {
    cout << 0;
    return 0;
  }
  vector<int> f(a + b + 1);
  f[0] = 1;
  for (int i = 1; i <= a + b; ++i) {
    f[i] = mul(f[i - 1], i);
  }
  cout << divide(f[a + b], mul(f[a], f[b]));

  return 0;
}

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

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

Measured memory_bytes: 256
X = int(input())

if X >=400 and X<=599:
    print("8")
elif X>=600 and X<= 799:
    print("7")
elif X>=800 and X<= 999:
    print("6")
elif X>=1000 and X<= 1199:
    print("5")
elif X>=1200 and X<= 1399:
    print("4")
elif X>=1400 and X<= 1599:
    print("3")
elif X>=1600 and X<= 1799:
    print("2")
elif X>=1800 and X<= 1999:
    print("1")
                                

Measured memory_bytes: 61640
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);

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

		if (b - a == c - b) {

			System.out.println("YES");

		} else {

			System.out.println("NO");

		}
	}
}


Measured memory_bytes: 21844
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;



int main() {
	int a, b, c; cin >> a >> b >> c;
	int ans;
	ans = a + b + c;
	if (ans >= 22) cout << "bust" << endl;
	else cout << "win" << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long dpF[][] = new long[n + 1][n + 1];
		long dpS[][] = new long[n + 1][n + 1];
		for ( int i = 1; i <= n; i++ ) {
			dpF[i][i] = in.nextInt();
			dpS[i][i] = 0;
		}
		in.close();

		for ( int base = 2; base <= n; base++ ) {
			int r = 1, c = base;
			while ( c <= n ) {

				if ( dpS[r + 1][c] + dpF[r][r] > dpS[r][c - 1] + dpF[c][c] ) {
					dpF[r][c] = dpS[r + 1][c] + dpF[r][r];
					dpS[r][c] = dpF[r + 1][c];
				} else {
					dpF[r][c] = dpS[r][c - 1] + dpF[c][c];
					dpS[r][c] = dpF[r][c - 1];
				}

				r++;
				c++;
			}
		}
		System.out.println(dpF[1][n] - dpS[1][n]);
	}
}

Measured memory_bytes: 232892
n,a,b,c,t;
main(){
    for(scanf("%d",&n);n--;t=0){
        scanf("%d%d%d",&a,&b,&c);
        a*=a;b*=b;c*=c;
        a+b==c?t=1:a+c==b?t=1:b+c==a?t=1:0;
      puts(t==1?"YES":"NO");
    }
}

Measured memory_bytes: 1692