akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 2e18 + 5;

const int MAX = 3005;
ll dp[MAX][MAX][4];
int val[MAX][MAX];
int main()
{
	boost;
	int n, m, k, i, j, x, y, c;
	cin >> n >> m >> k;
	fo(i, 0, k) {
		cin >> x >> y >> c;
		val[x][y] = c;
	}
	
	foe(i, 1, n) {
		foe(j, 1, m) {
			ll sum = 0;
			for(int k = 0; k <= 3; k++)
			sum = max(sum, dp[i - 1][j][k]);
			
			dp[i][j][0] = max(sum, dp[i][j - 1][0]);
			dp[i][j][1] = max({sum + val[i][j], dp[i][j - 1][1], dp[i][j - 1][0] + val[i][j]});
			dp[i][j][2] = max(dp[i][j - 1][1] + val[i][j], dp[i][j - 1][2]);
			dp[i][j][3] = max(dp[i][j - 1][2] + val[i][j], dp[i][j - 1][3]);
		}
	}
	cout << max({dp[n][m][0], dp[n][m][1], dp[n][m][2], dp[n][m][3]});
}


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

using NodeEdge = pair<int, int>; // 頂点番号,辺番号
using NodeEdgeList = vector<NodeEdge>;

void coloring(vector<NodeEdgeList> &nodes, int nextNodeNubmer, vector<int> &edgeColors, int prevEdgeNumber, int prevEdgeColor) {
    auto nodeEdges = nodes[nextNodeNubmer];
    auto currentColor = 0;
    rep(i, nodeEdges.size()) {
        NodeEdge edge = nodeEdges[i];
        auto nextNode = edge.first;
        if (edge.second == prevEdgeNumber) continue;
        if (currentColor == prevEdgeColor) currentColor++;
        edgeColors[edge.second] = currentColor;
        coloring(nodes, nextNode, edgeColors, edge.second, currentColor);
        currentColor++;
    }
}

int main() {
    int n;
    cin >> n;
    vector<NodeEdgeList> nodes(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        nodes[a].push_back(make_pair(b, i));
        nodes[b].push_back(make_pair(a, i));
    }
    int maxDeg = 0;
    int maxDegNodeNum = 0;
    rep(i, n) {
        int size = nodes[i].size();
        if (maxDeg <= size) {
            maxDeg = size;
            maxDegNodeNum = i;
        }
    }
    vector<int> edgeColors(n - 1);
    coloring(nodes, maxDegNodeNum, edgeColors, -1, -1);
    cout << maxDeg << endl;
    for (auto color : edgeColors) {
        cout << color + 1 << endl;
    }
}


Measured memory_bytes: 10112
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
	long long n,k;
	cin >> n >> k;
	if(k&1)
	{
		cout << (n/k)*(n/k)*(n/k);
		return 0;
	}
	long long x=n/(k/2);
	++x,x/=2;
	cout << (n/k)*(n/k)*(n/k)+x*x*x;
	return 0;
}

Measured memory_bytes: 888
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n = read(), a = read(), b = read();
    cout << min(n * a, b) << endl;

    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl
using namespace std;
using ll = long long;
const int INFINT = 1 << 30;
const ll INFLL = 1LL << 60;
const int MOD = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

int main() {

	int n;
	int X;

	cin >> n >> X;
	vector<int> x;
	int ans = 0;
	bool in = false;

	REP(i, n) {
		int t;
		cin >> t;
		x.push_back(t);
	}

	REP(i, n) {
		int d = abs(x[i] - X);
		ans = gcd(ans, d);
	}


	cout << ans NL;



	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <tuple>
#include <unordered_map>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;
 
namespace std {
    template <>
    class hash<tuple<llong, llong, llong> > {
    public:
        size_t operator()(const tuple<llong, llong, llong> &x) const {
            return hash<llong>()(get<0>(x)) ^ hash<llong>()(get<1>(x)) ^ hash<llong>()(get<2>(x));
        }
    };
}
 
llong n;
string str;
 
llong base[3] = {101, 117, 107};
llong basep[3][100005];
llong hsh[3][100005];
const llong mod = (llong)(1e9) + 7;
 
void build() {
    basep[0][0] = basep[1][0] = basep[2][0] = 1;
 
    for (int i = 0; i < 100003; i++) {
        basep[0][i + 1] = basep[0][i] * base[0] % mod;
        basep[1][i + 1] = basep[1][i] * base[1] % mod;
        basep[2][i + 1] = basep[2][i] * base[2] % mod;
    }
 
    for (int i = 0; i < str.size(); i++) {
        hsh[0][i + 1] = hsh[1][i + 1] = hsh[2][i + 1] = str[i];
    }
 
    for (int k = 0; k < 3; k++) {
        for (int i = 1; i < str.size(); i++) {
            hsh[k][i + 1] += hsh[k][i] * base[k] % mod;
            hsh[k][i + 1] %= mod;
        }
    }
}
 
tuple<llong, llong, llong> geth(llong l, llong r) {
    llong v1 = ((hsh[0][r] - hsh[0][l]*basep[0][r - l])%mod+mod)%mod;
    llong v2 = ((hsh[1][r] - hsh[1][l]*basep[1][r - l])%mod+mod)%mod;
    llong v3 = ((hsh[2][r] - hsh[2][l]*basep[2][r - l])%mod+mod)%mod;
 
    return make_tuple(v1, v2, v3);
}
 
int main() {
    cin >> n;
    cin >> str;
 
    build();
    
    for (llong len = n / 2; len >= 1; len--) {
        unordered_map<tuple<llong, llong, llong>, llong> cnt;
        for (llong s = 0; s + len <= n; s++) {
            tuple<llong, llong, llong> idx = geth(s, s + len);
            
            llong t = cnt[idx];
            if (t > 0) {
                if (s >= t) {
                    cout << len << endl;
                    return 0;
                }
            }
            else {
                cnt[idx] = s + len;
            }
        }
    }
 
    cout << 0 << endl;
 
    return 0;
}

Measured memory_bytes: 3512
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String[] s = { "Sunny", "Cloudy", "Rainy" };
		Map<String, Integer> map = new HashMap<>();
		map.put("Sunny", 1);
		map.put("Cloudy", 2);
		map.put("Rainy", 0);
		Scanner sc = new Scanner(System.in);
		System.out.println(s[map.get(sc.nextLine())]);
		sc.close();

	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  int a,b;cin>>a>>b;
  int c=a+b;
  if(c>=24)c-=24;
  cout<<c<<endl;
    return 0;
}

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

#define PI	(3.14159265358979323846264338)

void calcPoint( double* x, double* y, int* dir, int len, int deg )
{
	double dirRad = *dir * PI / 180.0;
	
	*x += sin( dirRad ) * len;
	*y += cos( dirRad ) * len;
	
	*dir += deg;
}

int main(void)
{
	double x = 0;
	double y = 0;
	int dir = 0;
	int len;
	int deg;
	
	while( 1 )
	{
		scanf( "%d,%d", &len, &deg );
		if( len == 0 && deg == 0 )break;
		
		calcPoint( &x, &y, &dir, len, deg );
	}
	printf( "%d\n%d\n", (int)x, (int)y );//*/
	
	return (0);
}

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

int main(){
    int n;
    cin >> n;
    if(n>=30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

class UnionFindTree
{
  public:
    vector<int> rank, p;

    UnionFindTree() {}
    UnionFindTree(int size)
    {
        rank.resize(size, 0);
        p.resize(size, 0);
        for (int i = 0; i < size; ++i)
            makeSet(i);
    }

    void makeSet(int x)
    {
        p[x] = x;
        rank[x] = 0;
    }

    bool is_same(int x, int y)
    {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y)
    {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y)
    {
        if (rank[x] > rank[y])
        {
            p[y] = x;
        }
        else
        {
            p[x] = y;
            if (rank[x] == rank[y])
            {
                ++rank[y];
            }
        }
    }

    int findSet(int x)
    {
        if (x != p[x])
        {
            p[x] = findSet(p[x]);
        }

        return p[x];
    }
};

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

    int N, M;
    cin >> N >> M;

    int commands[M][2];
    for (int i = 0; i < M; ++i)
    {
        cin >> commands[i][0] >> commands[i][1];
        --commands[i][0];
        --commands[i][1];
    }

    int ans = 0;
    for (int i = 0; i < M; ++i)
    {
        UnionFindTree utf = UnionFindTree(N);

        for (int j = 0; j < M; ++j)
        {
            if (i != j)
            {
                utf.unite(commands[j][0], commands[j][1]);
            }
        }

        int res = 0;
        for (int j = 0; j < N; ++j)
        {
            for (int k = j + 1; k < N; ++k)
            {
                if (!utf.is_same(j, k))
                {
                    ++res;
                }
            }
        }

        if (res)
            ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<cstdlib>
#define lson l,mid,o<<1
#define rson mid + 1,r,o<<1|1
#define sc(x) scanf("%d",&x);
#define For(i,a,b)  for(i = a; i <= b; i++)
typedef long long LL;
typedef unsigned long long uLL;
const int INF = 0x3f3f3f3f;
const LL MAX_N = 1e5 + 5;
const LL mod = 1e9 + 7;
const double PI = acos(-1);
using namespace std;
struct node{
    LL x,y;
}stu[100],no[100];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>stu[i].x>>stu[i].y;
    }
    for(int i=1;i<=m;i++){
        cin>>no[i].x>>no[i].y;
    }
    LL ans,now,mi;
    for(int i=1;i<=n;++i){
        mi=INF;
        ans=0;
        for(int j=1;j<=m;++j){
            now=abs(stu[i].x-no[j].x)+abs(stu[i].y-no[j].y);
            if(now<mi){
                ans=j;
                mi=now;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    int sum = 0;
    vi a(n);
    rep(i,n){
        int x; cin >> x;
        a[i] = x;
        sum += x;
    }
    int fro = 0;
    int ans = 1e9;
    rep(i,n-1){
        fro += a[i];
        sum -= a[i];
        chmin(ans,abs(sum-fro));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int d, n, t[200], a[200], b[200], c[200], dp[200][200] = {0};
int hds(int day, int sh){
  if(day == d) return 0;
  if(dp[day][sh]) return dp[day][sh];
  int ret = 0, v = 0;
  for(int i = 0; i < n; i++){
    if(a[i] <= t[day] && t[day] <= b[i]){
      if(day) v = abs(sh - c[i]);
      else v = 0;
      ret = max(ret, hds(day+1, c[i]) + v);
    }
  }
  return dp[day][sh] = ret;
}
int main(){
  cin >> d >> n;
  for(int i = 0; i < d; i++) cin >> t[i];
  for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
  cout << hds(0, 0) << endl;
}

Measured memory_bytes: 1336
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def is_ev_st(s):
    l = len(s)
    if l % 2 == 1:
        return False
    l2 = int(l / 2)
    return s[:l2] == s[l2:]


def main():
    S = get_ln_inputs()[0][:-1]
    while not is_ev_st(S):
        S = S[:-1]
    print(len(S))


main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};

int main() {
  vector<int> a;
  int q;
  cin >> q;
  rep(i, q) {
    int qu;
    cin >> qu;
    if(qu == 0) {
      int n;
      cin >> n;
      a.push_back(n);
    } else if(qu == 1) {
      int n;
      cin >> n;
      cout << a[n] << endl;
    } else {
      a.pop_back();
    }
  }
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  
  int a=N%10;
  
  if(a==2||a==4||a==5||a==7||a==9){
    cout << "hon" << endl;
  }
  else if(a==0||a==1||a==6||a==8){
    cout << "pon" << endl;
  }
  else{
    cout << "bon" << endl;
  }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
    int K, S;
    cin >> K >> S;
    
    int count=0;
    for(int x = 0; x <= K; x++){
        for(int y = 0; y <= K; y++){
                if(S - (x + y) >= 0 && S - (x + y) <= K) count++;
        }
    }
 
    cout << count << endl;
}

Measured memory_bytes: 3616
// Author: Mrigank
// Science is what we understand well enough to explain to a computer, Art is everything else we do - Donald E. Knuth
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <string> 
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair<int, int> PII;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < pair < ll , ll > > vpl;
typedef vector < pair < ll , bool > > vpb;
typedef vector < vector < int > > vvi;
typedef vector < vector < ll > > vvl;


#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x , val) memset(x , val , sizeof(x))
#define deb1(x) cout << x << endl
#define deb2(x , y) cout << x << " " << y << endl
#define deb3(x , y , z) cout << x << " " << y << " " << z << endl
#define all(x) x.begin() , x.end()
#define alls(x , y) x.begin() , x.end() , y
#define fastIO                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);


const ll mxsize = 5e6 + 5;
const ll linf = 1e9;
const ld inf = 10000000000.0;
const ll mod = 1e9 + 7;
 
/******************************************** CODE STARTS FROM HERE *************************************************/ 

int main()
{
    string s;
    cin >> s;
    bool ok = false;
    for(auto x : s)
    {
        if(x == '7')
        {
            ok = true;
            break;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

string s;

int main() {
  cin >> s;

  int MIN = 100;
  for(int i = 0; i < 26; i++) {
    string tmp = s;
    string ss = s;
    string one(s.length(), 'a' + i);
    int ans = 0;
    while(tmp != one) {
      for(int k = 0; k < tmp.length() - 1; k++) {
	if(ss[k+1] == ('a'+ i)) tmp[k] = ss[k+1];
	else tmp[k] = ss[k];
      }
      tmp.pop_back();
      one.pop_back();
      ss = tmp;
      ans++;
      //cout << tmp << endl;
    }
    MIN = min(MIN,ans);
    //cout << MIN <<"   "<< i+'a' <<endl;
  }

  cout << MIN << endl;
}
      
  


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
using namespace std;

void dfs(ll n){
	if (!n){
		cout << "Yes" << endl;
		exit(0);
	}if (n < 0) return;
	dfs(n - 4);
	dfs(n - 7);
}

int main(){
	ll n; cin >> n;
	dfs(n);
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import math
def f(p):
  k = math.atan2(p[1],p[0])
  return k+math.radians(180)
while True:
  n = int(input())
  if n == -1:
    break
  else:
    x = 1
    y = 0
    kakudo = 180
    n -= 1
    while n > 0:
      kakudo = f((x,y))
      kakudo -= math.radians(90)
      x += math.cos(kakudo)
      y += math.sin(kakudo)
      n -= 1
    print(x)
    print(y)

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

int main() {
	int x;
	cin >> x;
	if(30 <= x) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n], b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        double d1 = 0, d2 = 0, d3 = 0;
        int dm = 0;
        for (int i = 0; i < n; i++) {
            int d = Math.abs(a[i] - b[i]);
            d1 += d;
            d2 += d * d;
            d3 += d * d * d;
            dm = Math.max(dm, d);
            // System.out.printf("%f %f %f %f\n", d1, d2, d3, (float) dm);
        }
        d2 = Math.sqrt(d2);
        d3 = Math.cbrt(d3);
        System.out.printf("%f\n%f\n%f\n%f\n", d1, d2, d3, (float) dm);
    }
}

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

int main()
{
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int,int>;
const int INF = 1e18;
const int MOD = 1e9+7;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

signed main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    sort(rall(A));

    int ans = 0, res = 0;
{
    int n = A.size() / 2;

    rep(i,n) ans += A[i]*2;
    if(A.size() % 2 == 0) ans -= A[n - 1];

    for(int i = n; i < A.size(); i++) ans -= A[i]*2;
    ans += A[n];
    if(A.size() % 2 == 1) ans += A[n + 1];
}
{
    int n = A.size() / 2 + A.size() % 2;

    rep(i,n) res += A[i]*2;
    res -= A[n - 1];
    if(A.size() % 2 == 1 && n > 1) res -= A[n - 2];

    for(int i = n; i < A.size(); i++) res -= A[i]*2;
    if(A.size() % 2 == 0) res += A[n];
    
}
    cout <<  max(ans ,res) << endl;
}


Measured memory_bytes: 1152
d,g = map(int,input().split())
li = [list(map(int,input().split())) for i in range(d)]

ans = 10 ** 9
for i in range(2**d):
  ch = bin(i)[2:]
  ch = ch.zfill(d)
  tmpsum = 0
  cnt = 0
  for j in range(d):
    if ch[j] == "1":
      tmpsum += li[j][0]*100*(j+1) + li[j][1]
      cnt += li[j][0]
  if tmpsum >= g:
    ans = min(ans,cnt)
    #print("{} {}".format(bin(i),cnt))
  else:
    ind = ch.rfind("0")
    if tmpsum + (li[ind][0]-1)*100*(ind+1) >= g:
      ans = min(ans,cnt+(g-tmpsum-1)//(100*(ind+1))+1)
      #print("{} {} {}".format(bin(i),cnt,ans))
print(ans)

Measured memory_bytes: 3064
#!python3.4
# -*- coding: utf-8 -*-
# panasonic2020/panasonic2020_b
import sys, math

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    H, W = i2nn()
    if H == 1 or W == 1:
        print(1)
        return
    print(math.ceil(H * W / 2))
    return

main()


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

int N, K;
const int MAX_N = 2.0e5 + 10;
int A[MAX_N];

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> A[i];

    if (N <= K) {
        for (int i = 0; i < N; i++) {
            cout << N << " ";
        }
        cout << endl;
    }
    else {
        for (int i = 0; i < K; i++) {
            int B[N+1];
            memset(B, 0, sizeof(B));
            for (int j = 0; j < N; j++) {
                int l = max(0, j-A[j]);
                int r = min(N, j+A[j]+1);
                B[l]++;
                B[r]--;
            }
            for (int j = 0; j < N; j++) {
                B[j+1] += B[j];
            }
            bool all_N = true;
            for (int j = 0; j < N; j++) {
                if (B[j] != N) all_N = false;
                A[j] = B[j];
            }
            if (all_N) break;
        }

        for (int i = 0; i < N; i++) {
            cout << A[i] << " ";
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5180
A, B, C, X, Y = map(int, input().split())
AB = min(C*2,A+B)
A = min(A, C*2)
B = min(B, C*2)
ret = 0
while X + Y > 0:
	if X > 0 and Y > 0:
		ret += AB
		X -= 1
		Y -= 1
	elif X > 0:
		ret += A
		X -= 1
	elif Y > 0:
		ret += B
		Y -= 1
print(ret)

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

void Onigiri()
{
  int h,w;
  cin>>h>>w;
  char world[101][101];
  int wld[101][101];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin>>world[i][j];
  
  wld[0][0]=(world[0][0]=='#')?1:0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      {
        if(i==0&&j==0)continue;

        int ch1=INT_MAX;
        int ch2=INT_MAX;
        if(j!=0){if(world[i][j-1]==world[i][j])ch1=wld[i][j-1];else ch1=wld[i][j-1]+(world[i][j]=='#'?1:0);}
        if(i!=0){if(world[i-1][j]==world[i][j])ch2=wld[i-1][j];else ch2=wld[i-1][j]+(world[i][j]=='#'?1:0);}
        wld[i][j]=min(ch1,ch2);
      }
  
  // for(int i=0;i<h;i++)
  //   {for(int j=0;j<w;j++)
  //     cout<<wld[i][j]<<" ";
  //   cout<<endl;}

      cout<<wld[h-1][w-1]<<endl;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  if ( str.at(2) == str.at(3) && str.at(4) == str.at(5) ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine;
object Main {
    def main(args: Array[String]): Unit = {
        def go(line: String): Unit = {
            if (line != null) {
                val Array(a, b) = line.split(" ").map(_.toInt);
                val sum = a + b;
                println(sum.toString.length);
                go(readLine);
            }
        }
        go(readLine);
    }
}


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

int h,w;

int main(){
    while(true){
        cin>>h>>w;
        if(h==0&&w==0)return 0;
        else{
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(i==0||i==h-1||j==0||j==w-1)cout<<"#";
                    else cout<<".";
                }
                cout<<endl;
            }
            cout<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3092
n,k=map(int,input().split())
l=list(map(int,input().split()))
lcount=[0]*(n+1)
lnum=[0]*(n+1)
count=1
place=1
while lcount[place]==0:    
    lnum[place]=count
    lcount[place]=1
    place=l[place-1]
    count+=1 

dif=count-lnum[place]
if k+1<lnum[place]:
    print(lnum.index(k+1))
else:
    k=(k+1-lnum[place])%dif+lnum[place]
    print(lnum.index(k))
    

Measured memory_bytes: 32388
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    if (n >= 30) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    lli N, L;
    cin >> N >> L;
    vector<lli> v;
    for(lli i = 0; i < N; i++){
        v.push_back(L+i);
    }
    lli minv = LLONG_MAX;
    for(auto i : v){
        lli f = abs(i);
        if(f < abs(minv)) minv = i;
    }
    cout << accumulate(v.begin(), v.end(), 0) - minv << endl;
    return 0;
}


Measured memory_bytes: 256
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
bool f[200000+20];
vector<int> g[200000];
void dfs(vector<int>  &v,int now,vector<bool>& vis){
	vis[now]=1;
	for(auto it:g[now]){
		if(!vis[it]){
			v[it]=v[now]+1;
			dfs(v,it,vis);
		}
	}
}
int main(){
	fastio;
	int n;
	cin>>n;
	rep(i,n-1){
		int ai,bi;
		cin>>ai>>bi;
		ai--;
		bi--;
		g[ai].PB(bi);
		g[bi].PB(ai); 
	}
	vector<int> dis;
	int x,y;
	dis=vector<int> (n,0);
	vector<bool> tmp=vector<bool>(n,0);
	dfs(dis,0,tmp);
	x=0;
	rep(i,n)
	if(dis[i]>dis[x]) x=i;
	dis=vector<int> (n,0);
	tmp=vector<bool>(n,0);
	dfs(dis,x,tmp);
	y=x;
	rep(i,n)
	if(dis[i]>dis[y]) y=i;
	int len=dis[y];
	f[0]=1;
	f[1]=0;
	rep(i,len+1)
	{
		if(i<2) continue;
		rb(j,1,2){
			if(i>=j){
				f[i]|=(!f[i-j]);
			}
		}
//		cout<<f[i]<<endl;
	}
	cout<<(f[len]? "First":"Second")<<'\n'; 
	return 0;
}


Measured memory_bytes: 24832
#include <stdio.h>

int main(){
  int a[5];
  int k;
  for(int i = 0;i<5;i++){
    scanf("%d", &a[i]);
  }
  scanf("%d", &k);
  if(a[4] - a[0] <= k){
    
    if(a[3] - a[0] <= k && a[4] - a[1] <= k){
      
      if(a[2] - a[0] <= k && a[3] - a[1] <= k && a[4] - a[2] <= k){
	
	if(a[1] - a[0] <= k && a[2] - a[1] <= k && a[3] - a[2] <= k && a[4] - a[3] <= k){
	  printf("Yay!\n");
	}else{
	  printf(":(\n");
	}
	
      }else{
	printf(":(\n");
      }
      
    }else{
      printf(":(\n");
    }
    
  }else{
    printf(":(\n");
  }
}


Measured memory_bytes: 128
def main():
    n, *xy = map(int, open(0).read().split())
    f = [(i - j, i + j) for i, j in zip(xy[::2], xy[1::2])]
 
    a = max(x[0] for x in f)
    b = min(x[0] for x in f)
 
    c = max(x[1] for x in f)
    d = min(x[1] for x in f)
 
    ans = max(a - b, c - d)
    print(ans)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 56608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int[][] a = new int[5][2];
		int max = 0, sum = 0;
		for (int i = 0; i < 5; i++) {
			a[i][0] = sc.nextInt();
			if (a[i][0] % 10 == 0) {
				a[i][1] = a[i][0];
			} else {
				a[i][1] = (a[i][0] / 10 + 1) * 10;
			}
			max = Math.max(max, a[i][1] - a[i][0]);
			sum += a[i][1];
		}
		sum = sum - max;
		System.out.println(sum);
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=1005;
const int mod=1e9+7;
int dp[N][N];
char s[N][N];
int main()
{
int n,m;
scanf("%i %i",&n,&m);
for(int i=1;i<=n;i++)
scanf("%s",s[i]+1);
dp[1][1]=1;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
dp[i][j]+=dp[i-1][j]+dp[i][j-1];
dp[i][j]%=mod;
if(s[i][j]=='#')
dp[i][j]=0;
}
printf("%i",dp[n][m]);
return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> v(100);
  int a,b,k,cnt=0;
  cin>>a>>b>>k;
  for(int i=1;i<=100;++i){
    if(a%i==0&&b%i==0){
    cnt++;
    v[cnt]=i;
    }
  }
  
  cout<<v[cnt-k+1];
  return 0;
}

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

typedef long long ll;
const int maxn = 200200;

void solve()
{
    ll n;
    scanf("%lld", &n);
    ll base = 0;
    while(n){
        n/=2;
        base++;
    }
    ll ans = (1LL<<base) - 1;
    cout << ans << endl;
}

// 7 3 3 1 1

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





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
using Graph=vector<vector<int>>;

int main(){
  int H,W,K;
  cin>>H>>W>>K;
  vector<vector<int>> s(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char x;
      cin>>x;
      s.at(i).at(j)=x-'0';
    }
  }
  int ans=10000000;
  for(int i=0;i<(1<<(H-1));i++){
    bool flag2=false;
    int count=0;
    vector<int> a(H);
    int b=i;
    for(int j=0;j<H-1;j++){
      a.at(j)=b&1;
      b>>=1;
    }
    a.at(H-1)=1;
    for(int i=0;i<H;i++){
      count+=a.at(i);
    }
    int n=count;
    count-=1;
    vector<int> white(n,0);
    for(int j=0;j<W;j++){
      int kk=0;
      for(int k=0;k<H;k++){
        white.at(kk)+=s.at(k).at(j);
        if(a.at(k)==1){
          kk++;
        }
      }
      bool flag=false;
      for(int k=0;k<n;k++){
        if(white.at(k)>K){
          flag=true;
          break;
        }
      }
      if(flag){
        count++;
        for(int k=0;k<n;k++){
          white.at(k)=0;
        }
        int kk=0;
        for(int k=0;k<H;k++){
          white.at(kk)+=s.at(k).at(j);
          if(a.at(k)==1){
            kk++;
          }
        }
        for(int k=0;k<n;k++){
          if(white.at(k)>K){
            flag2=true;
            break;
          }
        }
      }
      if(flag2){
        break;
      }
    }
    if(flag2){
      continue;
    }
    ans=min(ans,count);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
//freopen("","r",stdin);
//freopen("","w",stdout);
ll POW(ll a,ll b,ll mod){
    ll ans = 1;
    while(b){
        if(b & 1)
            ans = (ans % mod * a % mod) % mod;
        b >>= 1;
        a = (a % mod * a % mod) % mod;
    }
    return ans;
}
ll combi(ll n,ll k){
  k=min(k,n-k);
  ll ans=1;
  ll ans2 = 1;
  //usa prop matematica c(n,r)=(n*(n-1)*..*1)/(r!*(n-r)!)
  //se cancelan el (n-r)! con el del numerador
  for(ll i=0;i<k;i++){

    //ans = (ans % mod * (n - i + mod) % mod) % mod;
    ans = (ans % mod * (n - i + mod) % mod) % mod;
    //cout<<ans<<" mult ans \n";
    ans2 = (ans2 % mod * (i + 1) % mod) % mod;
    //ans = (ans % mod * POW(i + 1,euler(i + 1) - 1, mod)) % mod;    //cout<<ans<<" div ans \n";
  }
  return (ans * POW(ans2,1000000005,mod)) % mod;
}
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    cout << (POW(2LL,n,mod) - 1LL + mod - combi(n,a) + mod - combi(n,b) + mod) % mod;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <iostream>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
inline void fastin(int &num) {
    int c;
    num = 0;
    c = getchar_unlocked();
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = num * 10 + c - 48;
}

inline void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}
 
int main(){   
    int n; fastin(n);
    int a[n];
    rep(i, n) fastin(a[i]);
 
    char c = 'E';  // state Up, Down, Equal
    int cnt = 1;
 
    for (int i = 1; i < n; ++i){
        if (a[i] > a[i - 1]){
            if (c == 'U'){
                continue;
            }
            else if (c == 'E'){
                c = 'U';
            }
            else if (c == 'D'){
                ++cnt; c = 'E';
            }
        }
        else if (a[i] == a[i - 1]){
            continue;
        }
        else if (a[i] < a[i - 1]){
            if (c == 'U'){
                ++cnt; c = 'E';
            }
            else if (c == 'E'){
                c = 'D';
            }
            else if (c == 'D'){
                continue;
            }
        }
    }
    fastout(cnt);
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll l,r,d;
    cin >> l>> r>>d;
    ll count=0;
    for(ll i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            count++;
        }
    }
    cout << count;

}


Measured memory_bytes: 3592
import static java.lang.Integer.parseInt;
import static java.lang.System.out;
import java.io.File;
import java.util.Scanner;

public class Main extends BaseExe {

    public static void main(String[] args) {
        new Main().exeSysIn();
    }

    @Override
    protected void execute(Scanner scan) {
        int[] lots = getLots(parseInt(scan.nextLine()));
        int crossCount = parseInt(scan.nextLine());
        for (int chageCount = 0; chageCount < crossCount; chageCount++) {
            changeLot(scan.nextLine().split(","), lots);
        }
        for (int lot : lots) {
            out.println(lot);
        }
    }

    private int[] getLots(int count) {
        int[] lots = new int[count];
        for (int lotIndex = 0; lotIndex < count; lotIndex++) {
            lots[lotIndex] = lotIndex + 1;
        }
        return lots;
    }

    private void changeLot(String[] changeNumbers, int[] lots) {
        int beforeIndex = parseInt(changeNumbers[0]) - 1;
        int afterIndex = parseInt(changeNumbers[1]) - 1;
        int tmp = lots[beforeIndex];
        lots[beforeIndex] = lots[afterIndex];
        lots[afterIndex] = tmp;
    }
}

abstract class BaseExe {

    public void exeSysIn() {
        try (Scanner scan = new Scanner(System.in)) {
            execute(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void exeFileIn(String inDataPath) {
        try (Scanner scan = new Scanner(new File(inDataPath))) {
            execute(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    protected abstract void execute(Scanner scan);
}

Measured memory_bytes: 26124
#include <iostream>
#include <vector>
#include <algorithm>
#include<string>

using namespace std;

int main(){
    int n = 0;
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '+'){
            n++;
        }
        if(s[i] == '-'){
            n--;
        }
    }

    cout << n << endl;

}

Measured memory_bytes: 256
import math
n=int(input())
m=int(math.sqrt(n))
i=0
while 1:
 if n%(m-i)==0 and n%(m+i+1)==0:
  print(min(int(math.log10(n/(m-i))),int(math.log10(m+i+1)))+1)
  break
 if n%(m-i)==0:
  print(int(math.log10(n/(m-i)))+1)
  break
 if n%(m+1+i)==0:
  print(int(math.log10(m+i+1))+1)
  break
 i+=1

Measured memory_bytes: 3060
#include<stdio.h>

void comp(int* a, int* b);

int main()
{
    int num, i;
    scanf("%d", &num);
    int dateSet[num][3];
    for(i=0; i<num; i++)
    {
        scanf("%d %d %d", &dateSet[i][0], &dateSet[i][1], &dateSet[i][2]);
        comp(dateSet[i], dateSet[i] + 1);
        comp(dateSet[i], dateSet[i] + 2);
        comp(dateSet[i] + 1, dateSet[i] + 2);
    }
    for(i=0; i<num; i++)
    {
        if((dateSet[i][0]*dateSet[i][0] + dateSet[i][1]*dateSet[i][1]) == (dateSet[i][2]*dateSet[i][2]))
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

void comp(int* a, int* b)
{
    int temp = 0;
    if(*a > *b)
    {
        temp = *a;
        *a = *b;
        *b = temp;
    }
}


Measured memory_bytes: 1728
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
//#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

typedef pair <int, int>point;
typedef pair <point, int>ppi;


int dx[] = { 0, -1, 0, 1 };
int dy[] = { 1, 0, -1, 0 };

int r, c;
char a[50][50];

int bfs(point s, point g) {
	queue <ppi> que;
	char b[50][50];
	que.push(ppi(s, 0)); //スタート地点とその距離が0であることを入力
	rep(i, r)rep(j, c)b[i][j]= a[i][j];
	while (!que.empty()) {
		int x = que.front().first.first;
		int y = que.front().first.second;
		int dist = que.front().second;
		que.pop();
		/*
		cout << " x="<<x<<" y="<<y<< "dist= "<<dist<<endl;
		rep(i, r){
			rep(j, c){
				cout << a[i][j];
			}
			println("");
		}
		println("");
		*/
		if (point(x, y) == g) return dist;
		rep(i, 4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx < 0 || r <= nx)continue;
			if (ny < 0 || c <= ny)continue;
			if (b[nx][ny] == '.') {
				b[nx][ny] = '#';//訪問済にする
				que.push(ppi(point(nx, ny), dist + 1));
			}
		}
	}
}


signed main(void) {
	cin >> r >> c;

	rep(i, r)rep(j, c)cin >> a[i][j];
	int ans = 0;
	//ans = bfs(point(2, 0), point(0, 4));
	rep(i, r) {
		rep(j, c) {
			if (a[i][j] == '#')continue;
			rep(k, r) {
				rep(l, c) {
					if (i == k && j == l)continue;
					else if (a[k][l] == '#')continue;
					else {
						ans = max(ans, bfs(point(i, j), point(k, l)));
					}
				}
			}
		}
	}
	print(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using lint=int64_t;
using namespace std;

bool cmp(pair<lint,lint> l,pair<lint,lint> r)
{
	if(l.first!=r.first)
		return l.first>r.first;
	return l.second>r.second;
}

int main()
{
	lint N,M;
	pair<lint,lint> p[100010]{};

	cin >> N >> M;
	for(lint i=0;i<N;i++)
	{
		cin >> p[i].first;
		cin >> p[i].second;
	}

	sort(p,p+N);

	priority_queue<lint> que;
	lint index=0;
	lint ans=0;
	for(lint i=1;i<=M;i++)
	{
		while(index<N && p[index].first<=i)
		{
			que.push(p[index].second);
			index++;
		}

		if(!que.empty())
		{
			ans+=que.top();
			que.pop();
		}
	}

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


Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n, a[100005];
int main() {
	scanf("%d", &n);
	for( int i = 0; i < n; i++ ) scanf("%d", &a[i]);
	int ans = 1, t = 0;
	for( int i = 0; i < n; i++ ){
		while( t<n && a[t] > (t-i)*2 ) t++;
		if( t<n && a[t]==(t-i)*2 ) t++;
		ans = 1LL*ans*(t-i)%mod;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
SERIES = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(SERIES[K-1])


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    REP(i, 0, N) {
        cin >> a[i];
    }
    vector<bool> win(K + 1);
    REP(i, 0, K + 1) {
        bool check = true;
        REP(j, 0, N) {
            if (i < a[j]) {
                check &= true;
            } else {
                check &= win[i - a[j]];
            }
        }
        win[i] = !check;
    }
    cout << (win[K] ? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	ll d, n;
	cin >> d >> n;
	
	if (n == 100 && d == 2) {
		cout << 1010000 << endl;
		return 0;
	}

	if (n == 100)n = 101;
	cout << n * pow(100, d) << endl;
	

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <numeric>
#include <vector>
#include <algorithm>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	string S;
	cin >> S;
	
	uint N = S.length() + 1;
	vector<uint> a(N);
	
	for(int i=0; i<S.length(); i++) {
		if(S[i] == '<') {
			a[i+1] = a[i] + 1;
		} 
	}
	
	for(int i=S.length()-1; i>=0; i--) {
		if(S[i] == '>' && a[i] <= a[i+1]) {
			a[i] = a[i+1] + 1;
		}
	}
	
	ull ans = accumulate(a.begin(), a.end(), ull(0));
	
	cout << ans;
}

Measured memory_bytes: 2820
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>

int main(void) {

	int a, b;

	std::cin >> a >> b;

	int count = 0;

	for (size_t i = a; i <= b; i++) {
		std::string s = std::to_string(i);

		std::string rev = s;
		std::reverse(rev.begin(), rev.end());

		if (s == rev) {
			count++;
		}
	}

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 256