akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x))
#define umin(m, x) (m = min(m, x))

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define bit(x, n) ((x) >> (n) & 1)
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    rep(i, n) cin >> p[i].first >> p[i].second;

    stack<vector<pair<int, int>>> s;
    s.push(p);

    while (!s.empty()) {
        auto cur = s.top(); s.pop();
        if (cur.size() == 8) {
            rep(i, 8) {
                rep(j, 8) {
                    bool f = true;
                    for (auto t : cur) {
                        if (t.first == i && t.second == j) {
                            cout << "Q";
                            f = false;
                            break;
                        }
                    }
                    if (f) cout << ".";
                }
                cout << endl;
            }
            return 0;
        }
        rep(i, 8) {
            rep(j, 8) {
                bool f = true;
                for (auto t : cur) {
                    if (
                        t.first == j ||
                        t.second == i ||
                        t.first - t.second == j - i ||
                        t.first + t.second == j + i
                    ) {
                        f = false;
                        break;
                    }
                }
                if (f) {
                    vector<pair<int, int>> pos;
                    copy(rng(cur), back_inserter(pos));
                    pos.push_back(make_pair(j, i));
                    s.push(pos);
                }
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3108
x,*s=open(0)
h,w,k,*m=map(int,x.split())
for b in range(512):
 r=t=j=0;d=[0]*h
 while w-j:
  i=c=0
  while h-i:
   d[c]+=s[i][j]>'0';x=d[c]>k
   if(t<j)&x:r+=1;t=j;d=[0]*h;break
   r+=h*w*x;c+=b>>i&1;i+=1
  else:j+=1
 m+=r+bin(b).count('1'),
print(min(m))

Measured memory_bytes: 44124
def f(yen, coin, cnt=0):
    while yen > 0: yen,r=divmod(yen,coin); cnt+=r
    return cnt

ans = n = int(input())
for yen6 in range(0, n+1):
    ans = min(ans, f(n-yen6, 9, f(yen6, 6)))
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
vector<ll> ret;
vector<ll> divisor(ll n) {
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return ret;
}
int main() {
    ll n;
    cin >> n;

    ll ans = 0;
    divisor(n);
    rep(i, ret.size()) {
        if (ret[i] == 1) continue;
        if (n / (ret[i] - 1) == n % (ret[i] - 1)) ans += (ret[i] - 1);
    }
/*
    ll ans2 = 0;
    rep(i, n) {
        if (i == 0) continue;
        if (n / i == n % i) ans2 += i;
    }
*/
    cout << ans << "\n";
//    cout << ans2 << "\n";
    return 0;
}

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

int main(void){
  int x,y;
  cin >> x >> y;
  if(x == 2 && y == 2){
    cout << "Yes" << '\n';
  }
  else if(x == 4 || x == 6 || x == 9 || x == 11){
    if(y == 4 || y == 6 || y == 9 || y == 11){
      cout << "Yes" << '\n';
    }
    else{
      cout << "No" << '\n';
    }
  }
  else if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12){
    if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12){
      cout << "Yes" << '\n';
    }
    else{
      cout << "No" << '\n';
    }
  }
  else{
    cout << "No" << '\n';
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <ctype.h>

using namespace std;


int main()
{
    int n,i;
    scanf("%d",&n);
        int a[n+1];
        for(i=1;i<=n;i++)
            scanf("%d",&a[i]);

        int k=1,cnt=0;
        while(true)
        {
            k=a[k];
            cnt++;
            if(cnt>=n)
            {
                cnt=-1;
                break;
            }
            if(k==2)
                break;
        }
        printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[200005];
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",min(b/a,c));
//    int n;
//    scanf("%d",&n);
//    for(int i=1; i<=n; i++)
//    {
//        scanf("%d",&a[i]);
//    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX_N (30)
#define NIL (-1)


typedef struct {
    int parent;
    int left;
    int right;
} Node;


void Preorder(int id);
void Inorder(int id);
void Postorder(int id);

Node node[MAX_N];
int n;
int root_id;

int main()
{
    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
	node[i].parent = NIL;
    }

    for ( int i = 0; i < n; i++ ) {
	int id, left, right;
	scanf("%d %d %d", &id, &left, &right);
	node[id].left = left;
	node[id].right = right;
	if ( left != NIL ) node[left].parent = id;
	if ( right != NIL ) node[right].parent = id;
    }    

    for ( int i = 0; i < n; i++ ) {
	if ( node[i].parent == NIL ) {
	    root_id = i;
	    break;
	}
    }

    printf("Preorder\n");
    Preorder( root_id );
    printf("\n");

    printf("Inorder\n");
    Inorder( root_id );
    printf("\n");

    printf("Postorder\n");
    Postorder( root_id );
    printf("\n");


    return 0;
}


void Preorder(int id)
{
    printf(" %d", id);
    if ( node[id].left != NIL ) Preorder( node[id].left );
    if ( node[id].right != NIL ) Preorder( node[id].right );

    return;
}


void Inorder(int id)
{
    if ( node[id].left != NIL ) Inorder( node[id].left );
    printf(" %d", id);
    if ( node[id].right != NIL ) Inorder( node[id].right );

    return;
}


void Postorder(int id)
{
    if ( node[id].left != NIL ) Postorder( node[id].left );
    if ( node[id].right != NIL ) Postorder( node[id].right );
    printf(" %d", id);

    return;
}

Measured memory_bytes: 1048
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            var count = 0;

            for (var i = 1; i < N.Length; i++)
            {
                if (N[i] == N[i - 1])
                {
                    count++;
                    if (count == 2) break;
                }
                else count = 0;
            }
            Console.WriteLine(count == 2 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	string s, t;
	cin>>s;
	cin>>t;
	bool pos = true;
	for(int i=0; i<s.length();i++)
	{
		if(s[i]!=t[i])
		{
			pos = false;
			break;
		}
	}
	if(pos)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
    int i,n,count=0;
    int p[30];

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

    for(i=0; i<n-2; i++){
        if(((p[i]<p[i+1])&&(p[i+1]<p[i+2]))||((p[i]>p[i+1])&&(p[i+1]>p[i+2]))) count++;
    }

    printf("%d\n",count);
    
    return 0;
}

Measured memory_bytes: 128
from collections import deque
n = int(input())
k = 0
data = [[] for _ in range(n)]
ans_index = []

for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    data[a].append(b)
    ans_index.append(b)

q = deque([0])
color = [0] * n
while q:
    cur = q.popleft()
    c = 1
    for x in data[cur]:
        if c == color[cur]:
            c += 1
    
        color[x] = c
        c += 1
        q.append(x)

print(max(color))
for i in ans_index:
    print(color[i])

Measured memory_bytes: 23168
N,M = map(int,input().split())
L = list(list(map(int,input().split())) for i in range(M))

A = [1 for i in range(N+1)]

red = [0 for i in range(N+1)]
red[1] = 1

ans = 1
for i in range(M) :
    A[L[i][0]] -= 1
    A[L[i][1]] += 1
    if red[L[i][0]] == 1 :
        red[L[i][1]] = 1
    if A[L[i][0]] == 0 :
        red[L[i][0]] = 0
        
ans = sum(red)
print(ans)


Measured memory_bytes: 67672
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;

int cost[31][31];
int a[510][510];
int cnt[3][31];

int main(){
    int n, c, ans = INF;
    cin >> n >> c;
    for(int i = 0; i < c; i++) for(int j = 0; j < c; j++) cin >> cost[i][j];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
            a[i][j]--;
            cnt[(i + j) % 3][a[i][j]]++;
        }
    }
    for(int i = 0; i < c; i++){
        for(int j = 0; j < c; j++){
            for(int k = 0; k < c; k++){
                if(i == j || j == k || k == i) continue;
                int tmp = 0;
                for(int before = 0; before < c; before++){
                    tmp += cost[before][i] * cnt[0][before] + cost[before][j] * cnt[1][before] + cost[before][k] * cnt[2][before];
                }
                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

bool is_finish(string s)
{
    string str;
    stringstream ss(s);
    while (ss >> str) {
        if (str == "the" ||
            str == "this" ||
            str == "that") return 1;
    }
    return 0;
}

int main()
{
    string s;
    while (getline(cin, s)) {
        s.pop_back();
        for (int i = 0; i < 26; i++) {
            for (char &c: s) {
                if (islower(c)) {
                    c = c + 1;
                    if (c > 'z') c = 'a';
                }
            }
            if (is_finish(s)) {
                break;
            }
        }
        cout << s << "." << endl;
    }
    return 0;
}

Measured memory_bytes: 3044
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int N;
	cin >> N;
	int S[N];
	char buf;
	int ret=N+1,cnt=0;
	scanf("%c",&buf);
	REP(i,N){
		scanf("%c",&buf);
		S[i] = (buf=='E') ? 1 : 0;
		cnt+= S[i];
	}
	cnt -= S[0];
	ret = cnt;
//	errln(cnt);
	FOR(i,1,N-1){
		cnt = cnt - S[i] + (1- S[i-1]);
		ret = min(cnt,ret);
//		errln(cnt);
	}
	println(ret);
}



Measured memory_bytes: 1408
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
max_a = max(A)
u = max_a
d = 0
res = 9
max_do = math.ceil(math.log(max_a*10,2))
for _ in range(max_do):
    n = (u + d)/2
    _k = 0
    for _a in A:
        _k += math.ceil(_a/n) - 1
    
    if _k > K:
        d = n
    else:
        u = n
print(math.ceil(n))

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

    long long A, B;       cin >> A >> B;
    if((A % 2 == 0 && B % 2 != 0) || (A % 2 != 0 && B % 2 == 0))
        cout << "IMPOSSIBLE" << endl;
    else{
        long long ans = min(A, B) + (max(A, B) - min(A, B)) / 2;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d,i,j,area1,area2;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	area1=a*b;
	area2=c*d;
	if(area1>=area2)
	 printf("%d\n",area1);
	else
	 printf("%d\n",area2);
	return 0;
}

Measured memory_bytes: 128
import sys
# input = sys.stdin.readline
inf = 10 ** 18

N = int(input())
A = list(map(int, input().split()))

x_1 = sum(A) // 2
for i in range(N):
    if i % 2:
        x_1 -= A[i]

x = [2 * (x_1)]
x_l = x_1
for i in range(N - 1):
    x.append(2 * (A[i] - x_l))
    x_l = A[i] - x_l

print(' '.join(map(str, x)))

Measured memory_bytes: 19144
import bisect, heapq
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

j, bef = 0, -1
for i in range(N):
    if A[i] != bef:
        j = 0
    if A[i] == B[i]:
        while j < N:
            if A[j] != B[i] and B[j] != A[i]:
                B[i], B[j] = B[j], B[i]
                break
            j += 1
        if A[i] == B[i]:
            print("No")
            exit()

    bef = A[i]

print("Yes")
for b in B:
    print(b,end=" ")
print("")





Measured memory_bytes: 105992
/*
ID: yzshang1
LANG: C++11
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;

int main() {
	int n, m;
	cin >> n >> m;
	char a = n + '0', b = m + '0';
	string s1, s2;
	repn(i, m) s1 += a; repn(i, n) s2 += b;
	cout << min(s1, s2) << endl;
	return 0;
}


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

int main(){
    long N,K;
    cin>>N>>K;
    vector<long long> p(N);
    for(int i=0;i<N;i++){
        cin>>p.at(i);
        ++p.at(i);
    }
    vector<long long> s(N+1,0);
    for (int i=0;i<N;i++){
        s.at(i+1)=s.at(i)+p.at(i);
    }
    long long res = 0;
    for (int i=0;i+K<=N;i++){
        res =max(res,s.at(i+K)-s.at(i));
    }
    cout<<fixed<<setprecision(10)<<(double)(res)/2<<endl;
}


Measured memory_bytes: 3456
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define ll int
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;
string s;
ll ans;
ll A[2002];
ll dp[4002][4002];
ll cnt=0;
ll mod = 998244353;
ll N,r,b;
int main()
{
  cin>>s;
  N=s.size();
  rep(i,N){
    A[i+1]=0;
    if(s[i]=='1') A[i+1]=1;
    else if(s[i]=='2') A[i+1]=2;
  }
  //rep1(i,N) cout<<A[i]<<endl;
  //cout<<"asd"<<endl;
  dp[0][0] = 1;
  rep1(i,2*N){
    if(i<=N) cnt+=2;
    
    rep(j,2*N){ // dp[i-1][j]
      r = i<=N ? j + A[i] : j;
      b = cnt-r;
      if(b > 0 && r <= 2*N) dp[i][r] = (dp[i][r]+dp[i-1][j])%mod; //青
      if(r > 0 && r <= 2*N)  dp[i][r-1] = (dp[i][r-1] + dp[i-1][j])%mod;
    }
    cnt-=1;
  }
  // rep(i,2*N+1){
  //   rep(j,2*N+1){
  //     cout<<dp[i][j]<<"a"<<i<<"b"<<j<<endl;
  //   }
  // }
  cout<<dp[2*N][0]<<endl;
}


Measured memory_bytes: 62848
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int MOD = (int) 1e9 + 7;
void sadd(int &a, int b)
{
	a += b;
	if (a >= MOD)
		a -= MOD;
}
int add(int a, int b)
{
	sadd(a, b);
	return a;
}
int mul(int a, int b)
{
	return (a * 1LL * b) % MOD;
}
void smul(int &a, int b)
{
	a = mul(a, b);
}

const int N = 5005;
int C[N][N];

int getC(int a, int b)
{
	if (a < 0 || b < 0 || b > a) return 0;
	return C[a][b];
}

void init()
{
	for (int i = 0; i < N; i++)
	{
		C[i][0] = C[i][i] = 1;
		for (int j = 1; j < i; j++)
			C[i][j] = add(C[i - 1][j - 1], C[i - 1][j] );
	}
}


int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	init();

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

	if (b % 2 != 0)
	{
		printf("0\n");
		return 0;
	}
	int ans = 0;
	int blocks = b / 2;
	for (int c3b = 0; c3b <= c; c3b++)
	{
		int cur = (c3b == 0 ? 1 : getC(blocks + c3b - 1,c3b) );
		for (int c1 = 0; c1 <= a; c1++)
		{
			int c31 = a - c1;
			int c333 = (c - c31 - c3b) / 3;
			if (c31 < 0 || c333 < 0) continue;
			if (c31 + c3b + 3 * c333 != c) continue;
			int loc = cur;
			smul(loc, getC(blocks + c31, c31) );
			smul(loc, getC(blocks + c31 + c333, c333) );
			smul(loc, getC(blocks + c31 + c333 + c1, c1) );
			sadd(ans, loc);
		}
	}
	printf("%d\n", ans);

	return 0;
}



Measured memory_bytes: 67200
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int x,t;
    cin >> x >> t;
    cout << max(x-t,0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define ll long long

int main(){
  char s[7];
  int i;
  scanf("%s", s);
  if(s[2]==s[3]&&s[4]==s[5]) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
int main() {
  string s;
  cin >> s;
  if (s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main()
{
    int i, n, r[200000];
    int max = -1000000000, min;
    
    scanf("%d", &n);
    scanf("%d", &r[0]);
    min = r[0];
    for (i = 1; i < n; i++){
        scanf("%d", &r[i]);
        if (max < r[i] - min) max = r[i] - min;
        if (min > r[i]) min = r[i];
    }
    printf("%d\n", max);
    
    return 0;
}

Measured memory_bytes: 1376
#include <cstdio>
#include <algorithm>
using namespace std;

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

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


    sort(a, a+3*N);

    long long sum=0;
    for (int i = 0; i < N; i++){
        sum += a[3*N-(2*i+1)-1];
    }
    printf("%lld\n", sum);

    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	int cnt=0,ans=0;
	for (int i = 0; i < n-1; ++i)
	{
		if (a[i]==a[i+1])
		{
			++cnt;
		}
		else
		{
			ans+=(cnt+1)/2;
			cnt=0;
		}
	}
	ans+=(cnt+1)/2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n;
	scanf("%d",&n);
	if(n%10==7)
	{
	    printf("Yes");
	    return 0;
	}
	n=n/10;
	if(n%10==7)
	{
	    printf("Yes");
	    return 0;
	}
	n=n/10;
	if(n%10==7)
	{
	    printf("Yes");
	    return 0;
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using namespace std;
using ll = long long;
int main()
{
  int n,m;
  int ans=1;
  scanf("%d %d",&n,&m);
  int sum=0;

  vector<int> a(n,-1);
  int b,c;
  rep(i,m){
    scanf("%d %d",&b,&c);
    if(a.at(b-1)==-1) a.at(b-1) = c;
    else if(a.at(b-1)!=c) ans=0;
  }
  
  if(a.at(0)==0 && n!=1) ans=0;
  if(a.at(0)==-1 && n!=1) a.at(0)=1;
  
  rep(i,a.size()){
    if(a.at(i)==-1) continue;
    sum += a.at(i) * pow(10,(n-i-1));
  }

  if(ans==1) printf("%d\n",sum);
  else printf("%d\n",-1);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define X first
#define Y second
#define sz(a) (int)a.size()
 
void solve();
 
main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ONPC
	freopen("in.txt", "r", stdin);
#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	return 0;
}
 
const int N = 2005;
int n, dp[3 * N][3 * N], pref[2][3 * N][3 * N], pos[2][3 * N];
vector<pair<char, int>> v;
 
void solve() {
	cin >> n;
	for (int i = 1; i <= 2 * n; ++i) {
		char c;
		int x;
		cin >> c >> x;
		v.pb({c, x});
		for (int j = 0; j <= n; ++j) pref[0][i][j] = pref[0][i - 1][j], pref[1][i][j] = pref[1][i - 1][j];
		if (c == 'W') {
			pos[0][x] = i;
			for (int j = 0; j <= n; ++j) pref[0][i][j] += (x > j);
		} else {
			pos[1][x] = i;
			for (int j = 0; j <= n; ++j) pref[1][i][j] += (x > j);
		}
	}
	dp[0][1] = pref[0][pos[1][1]][0] + pref[1][pos[1][1]][1];
	dp[1][0] = pref[0][pos[0][1]][1] + pref[1][pos[0][1]][0];
//	cout << dp[0][1] << '\n' << dp[1][0] << '\n';
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			if (i == 0 && j == 0) continue;
			dp[i][j] = 1e9 + 7;
			if (i != 0) dp[i][j] = min(dp[i][j], dp[i - 1][j] + pref[0][pos[0][i]][i] + pref[1][pos[0][i]][j]);
			if (j != 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + pref[0][pos[1][j]][i] + pref[1][pos[1][j]][j]);
//			dp[i][j] = min(dp[i - 1][j] + pref[0][pos[0][i]][i] + pref[1][pos[0][i]][j], dp[i][j - 1] + pref[0][pos[1][j]][i] + pref[1][pos[1][j]][j]);
//			cout << i << ' ' << j << ' ' << dp[i][j] << '\n';
		}
	}
	cout << dp[n][n];
}

Measured memory_bytes: 234752
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;
    int sum = 0;
    for (int i=A; i<=B; i++) {
        string s = to_string(i);
        string r = s;
        reverse(r.begin(), r.end());
        if (s == r) {
            sum += 1;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, k; cin >> n >> k;
    map<char, ll> mp;
    cin >> mp['s'] >> mp['p'] >> mp['r'];
    string s; cin >> s;
    vector<bool> iswin(n);
    ll score = 0;
    rep(i, n) {
        if (i < k) {
            iswin[i] = true;
            score += mp[s[i]];
            continue;
        }

        if (s[i] == s[i-k] && iswin[i-k]) iswin[i] = false;
        else {
            iswin[i] = true;
            score += mp[s[i]];
        }
    }
    cout << score << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<vector>
#include<map>
#define INF 10000000
#define to first
#define cost second
using namespace std;
typedef pair<int,int> P;
vector<P> e[3000];
int d[3000];
bool used[3000];
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
int abs(int a){return a>=0?a:-a;}
int round(int a){return a%2==0?a/2:(a+1)/2;}
int n,m,ns;
void dykstra(){
	int i,j;
	while(1){
		int v=-1;
		for(i=0;i<n;i++)if(!used[i]&&(v==-1||d[i]<d[v]))v=i;
		if(v==-1)break;
		used[v]=true;
		for(i=0;i<e[v].size();i++){
			int u=e[v][i].to;
			int cos=e[v][i].cost;
			d[u]=min(d[u],d[v]+cos);
		}
	}
}
int main(){
	int i,j;
	scanf("%d %d %d",&n,&m,&ns);
	for(i=0;i<n;i++){
		d[i]=INF;
		used[i]=false;
	}
	for(i=0;i<m;i++){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		a--;b--;
		e[a].push_back(P(b,c));
		e[b].push_back(P(a,c));
	}
	for(i=0;i<ns;i++){
		int s;
		scanf("%d",&s);
		s--;
		d[s]=0;
	}
	dykstra();
	int ans=0;
	for(i=0;i<n;i++){
		ans=max(ans,d[i]);
		for(j=0;j<e[i].size();j++){
			int u=e[i][j].to;
			int cos=e[i][j].cost;
			if(abs(d[i]-d[u])<cos)ans=max(ans,round(d[i]+d[u]+cos));
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3956
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    h: i64,
    s: [(i64, i64); n],
  }
  let max_a = s.iter().map(|&(a, _)| a).max().unwrap();
  let mut bs: Vec<i64> = s.iter().filter_map(|&(_, b)| if b > max_a { Some(b) } else { None }).collect();
  bs.sort();
  let mut h = h;
  let mut count = 0i64;
  for &b in bs.iter().rev() {
    if h <= 0 {
      break;
    }
    h -= b;
    count += 1;
  }
  if h > 0 {
    count += (h + max_a - 1) / max_a;
  }

  println!("{}", count);
}


Measured memory_bytes: 9464
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
void cmn(int &a, const int b) {
	a = min(a, b);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (int i = 0; i < N; i++) {
		if (A[i] == 0) {
			B[i] = 2;
		}
		else {
			B[i] = A[i] % 2;
		}
	}

	for (int i = 0; i < N; i++) {
		C[i] = 1 - (A[i] % 2);
	}
	vector<vector<int> > dp(N + 1, vector<int>(5, (int)1 << 60));
	dp[0][0] = 0;

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 5; j++) {
			cmn(dp[i][4], dp[i - 1][j] + A[i - 1]);
			if (j <= 3) {
				cmn(dp[i][3], dp[i - 1][j] + B[i - 1]);
				if (j <= 2) {
					cmn(dp[i][2], dp[i - 1][j] + C[i - 1]);
					if (j <= 1) {
						cmn(dp[i][1], dp[i - 1][j] + B[i - 1]);
						if (j == 0) {
							cmn(dp[i][0], dp[i - 1][j] + A[i - 1]);
						}
					}
				}
			}
		}
	}

	res = (int)1 << 60;
	for (int i = 0; i < 5; i++) {
		cmn(res, dp[N][i]);
	}
	cout << res << endl;
}

Measured memory_bytes: 19072
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll a = x/11;
    ll b = x%11;
    if(b == 0) {
        out(2*a);
    }
    else if(b <= 6) {
        out(2*a+1);
    }
    else {
        out(2*a+2);
    }

    re0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
 		int n = scan.nextInt();
		String S = scan.next();
		int a[] = new int[n];
		int x[] = new int[n];
		int y[] = new int[n];

		for(int i=0;i<n;i++) {
			a[i] = S.substring(i, i+1).equals("E") ? 0:1;
		}

		x[0] = a[0];
		y[n-1] = a[n-1] == 0 ? 1:0;

		for(int i=1;i<n;i++){
			x[i] = x[i-1] + a[i];
		}

		for(int i=n-2;i>=0;i--){
			y[i] = y[i+1] + (a[i]-1)*-1;
		}

		int min = Integer.MAX_VALUE;
		for(int i=1;i<n-1;i++){
			int minj = x[i-1] + y[i+1];

			min = Math.min(minj,min);
		}
		min = Math.min(x[n-2],min);
		min = Math.min(y[1],min);

		System.out.println(min);
	}
 
}

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


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

    double len = pow(n, 0.5);
    int ans = 20;
    for(int i = 1; i <= len; i++)
    {
        if(n % i == 0){
            int j = n / i;
            string istr = to_string(i), jstr = to_string(j);
            ans = min(ans, max((int)istr.size(), (int)jstr.size()));
        }
    }
    
    cout << ans << endl;
    
    
	return 0;
}

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

ll calc(ll a) {
  if (a <= 0) return 0;

  // 4の時 0,1,2,3,4までになるので、これは5つの整数までなので調整
  a++;
  ll ans = 0;
  // i桁目の偶奇を調べる
  for (int i = 0; i < 50; i++) {
    ll loop = (1LL << (i + 1));
    // loopする回数 * 1が出てくる回数
    ll cnt = (a / loop) * (loop / 2);
    //00000.....0011111.....11
    //上の1の数を数えたい
    //端数を求めてそこから0の数を引く
    cnt += max(0LL, (a % loop) - (loop / 2));

    if (cnt % 2 == 1) {
      ans += 1LL << i;
    }
  }
  return ans;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll ans = calc(b) ^ calc(a - 1);
  cout << ans << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
swiches=[]
for i in range(m):
	s=0
	for j in list(map(int,input().split()))[1:]:
		s+=2**(j-1)
	swiches.append(s)
pli=list(map(int,input().split()))
cnt=0
for i in range(2**n):
	flag=True
	for p,s in zip(pli,swiches):
		if p!=bin(i&s).count("1")%2:
			flag=False
			break
	if flag:
		cnt+=1
print(cnt)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int n; cin >> n;
    vector<string> b_a, b_, _a, non;
    rep(i, n){
        string s; cin >> s;
        if(s[0] == 'B' && s.back() == 'A') b_a.push_back(s);
        else if(s[0] == 'B')b_.push_back(s);
        else if(s.back() == 'A')_a.push_back(s);
        else non.push_back(s);
    }
    string res;
    if(!_a.empty()){
        res += _a[0];
        _a.erase(_a.begin());
    }
    for(string t: b_a){
        res += t;
    }
    int siz_a = _a.size(), siz_b = b_.size();
    for(int i=0; i<min(siz_a, siz_b); i++){
        res += b_[i]; res += _a[i];
    }
    if(siz_a > siz_b){
        for(int i=siz_b; i< siz_a; i++) res += _a[i];
    }else{
        for(int i=siz_a; i<siz_b; i++) res += b_[i];
    }
    for(string t: non){
        res += t;
    }

    int cnt = 0;
    rep(i, res.size()-1){
        if(res[i] == 'A' && res[i+1] == 'B') cnt++;
    }
    cout << cnt << ln;
}

Measured memory_bytes: 896
#include<stdio.h>

int main(void){
	int a,b,c;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0){
			break;
		}
		if(a>b){
			c=a;
			a=b;
			b=c;
		}
		printf("%d %d\n",a,b);
	}
	return 0;
	
}

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

constexpr ll INF = ll(1e+18) + 1;

int main() {
    int N;

    cin >> N;
    vector<int> ans(N+1);

    for (int x = 1; x*x <= N; x++) {
        for (int y = 1; x*x + y*y + x*y <= N; y++) {
            for (int z = 1; x*x + y*y + z*z + x*y + y*z + z*x <= N; z++) {
                ans[x*x + y*y + z*z + x*y + y*z + z*x]++;
            }
        }
    }

    for (int i = 1; i <= N ; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  ll n; cin >> n;
  stack<int> num;
  while (n != 1 && n != 0) {
    if (n & 1) {
      num.push(1);
      n--;
      n /= -2;
    } else {
      num.push(0);
      n /= -2;
    }
  }
  if (n==1) num.push(1);
  else num.push(0);
  while (num.size()) {
    printf("%d", num.top());
    num.pop();
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<pll> p;
	rep(i,n){
		int a,b; cin>>a>>b;
		p.emplace_back(a,b);
	}
	ll ans=INF;
	if(n==1)ans=1;
	rep(i,n)range(j,i+1,n){
		ll x=p[i].fs-p[j].fs, y=p[i].sc-p[j].sc;
		ll val=0;
		vector<bool> v(n,false);
		rep(k,n){
			if(v[k])continue;
			val++;
			queue<int> que;
			que.push(k);
			while(!que.empty()){
				ll pos;
				pos=que.front(); que.pop();
				if(v[pos])continue;
				v[pos]=true;
				rep(l,n){
					if(p[l].fs-p[pos].fs==x and p[l].sc-p[pos].sc==y){
						que.push(l);
					}
					if(p[l].fs-p[pos].fs==-x and p[l].sc-p[pos].sc==-y){
						que.push(l);
					}
				}
			}
		}
		chmin(ans,val);
	}
	puta(ans);
	return 0;
}

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

void sort(int ar[],int l,int r);

int compare(const void *a, const void *b){
	return *(int *)b - *(int *)a;
}

int main(void){

	int n,h,i,j,tmp,max=0,cnt=0;

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

	int a[n],b[n];

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

	qsort(b,n,sizeof(int),compare);
	
	for(i=0;h>0 && i<n && max<b[i];i++){
		h-=b[i];
		cnt++;
	}
	if(h>0){
		cnt+=h/max;
		if(h%max!=0){
			cnt++;
		}
	}

	printf("%d",cnt);

	return 0;

}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> pll;

const int N = 2e5+5;
int n;
pll a[N];

bool cmpr(pll x, pll y){
    if(x.second == y.second){
        return x.first > y.first;
    }
    return x.second < y.second;
}

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

    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i].first >> a[i].second;
    }
    sort(a+1,a+1+n,cmpr);
    long long time = 0;
    bool flag = true;
    for(int i=1;i<=n;i++){
        time += a[i].first;
        if(time > a[i].second){
            flag = false;
            break;
        }
    }
    puts(flag ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 3456
//***Blessed are the curious for they shall have adventures********

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
    ll n;
    cin>>n;
    cout<<(n*n*n);
}

Measured memory_bytes: 256
from sys import stdin

# 数値への変換
n = int(stdin.readline().rstrip())

def main():
    keta = len(str(n))
    odd = [ i for i in range(1,(n + 1)) if len(str(i)) % 2 != 0 ]
    print("{}".format(len(odd)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 6720
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

MOD = 10 ** 9 + 7
def my_pow(base, n, mod):
    if n == 0:
        return 1
    x = base
    y = 1
    while n > 1:
        if n % 2 == 0:
            x *= x
            n //= 2
        else:
            y *= x
            n -= 1
        x %= mod
        y %= mod
    return x * y % mod

N = int(input())

adj = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1    
    b -= 1
    adj[a].append(b)
    adj[b].append(a)

pows = [1] * N
for i in range(1, N):
    pows[i] = (pows[i - 1] * 2) % MOD

ans = 0
def dfs(v, p):
    global ans
    subs = []
    res = 1
    for u in adj[v]:
        if u == p:
            continue
        val = dfs(u, v)
        res += val
        subs.append(val)
    # add sub-tree on the parent side
    if p != -1:
        subs.append(N - res)
    now = pows[N - 1] - 1 # N - 1 means that it chooses freelye other than v
    for sub in subs:
        now -= pows[sub] - 1
    ans += now
    ans %= MOD
    return res

dfs(0, -1)
print(ans * my_pow(2 ** N, MOD - 2, MOD) % MOD)

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

int main(){
    int S, h, m, s;
    cin >> S;
    if (S >= 0 && S <= 86400) {
        h = S / 3600;
        S = S - h * 3600;
        m = S / 60;
        s = S % 60;
        cout << h << ":" << m << ":" << s << endl;
    }
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;


int main(){
    string s,t;cin >>s>>t;
    ll n=s.size();
    bool flg=true;
    for (int i = 0; i <n; ++i) {
        if(s[i]!=t[i])flg=false;
    }
    if(t.size()!=s.size()+1)flg=false;
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        long g = gcd(c,d);
        long q = c * d / g;
        long r = b - a - (((b / c - (a - 1) / c) + b / d - (a - 1) / d) - b / q + (a - 1) / q) + 1;
        System.out.println(r);
    }
    public static long gcd(long a,long b) {
        if(a % b == 0) {
            return b;
        }
        return gcd(b,a % b);
    }
}

Measured memory_bytes: 21716
//Longest Increasing Subsequence
#include<bits/stdc++.h>
using namespace std;


#define INF 1234567890
int a[100000];
int dp[100000];

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

  for(int i=0; i<n; i++)
    *lower_bound(dp, dp+n, a[i])=a[i];

  cout<<lower_bound(dp, dp+n, INF)-dp<<endl;
  return 0;
}

Measured memory_bytes: 1940
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String a;
		int count=0;
		while(true){
			a = sc.next();
			if(a.equals("END_OF_TEXT"))break;
			a = a.toLowerCase();
			if(a.equals(str.toLowerCase()))count++;
		}
		System.out.println(count);
	}
}


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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int n;
    cin >> n;

    vector<ll> v(n);

    rep(i, n){
        cin >> v[i];
    }

    sort(ALL(v));
    reverse(ALL(v));

    ll ans = 0;

    ans += v[0];

    for(int i = 2; i < n; i++){
        ans += v[i / 2];
    }

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


Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
bool compare(pair<ll,ll> p1,pair<ll,ll> p2){
return p1.se<p2.se;
}
void solve(){
ll n;
cin>>n;
bool ans=0;
while(n>0){
if(n%10==7) ans=1;
n/=10;
}
ans?yes:no;
}
int main()
{   fast;
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3636
import java.util.*;
public class Main{
	public static void main(String[] args){
		int sum = 0;
		int all = 0;
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int l = sc.nextInt();
      	int[] array = new int[n];
      	int[] array2 = new int[n];
      	for(int i = 0;i < n;i++){
      		array[i] = l+i;
          	array2[i] = Math.abs(array[i]);
      	}
      	sum = array2[0];
      	for(int j = 0;j < n;j++){
      		sum = Math.min(sum, array2[j]);
      		if(sum == array2[j]) {all = array[j];}
        }
      	System.out.println((n*(l*2+n-1))/2-all);
      	sc.close();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h> 
  using namespace std; 
  #define ll long long
  int main()
  {
   ll n,k,sum=0;
   cin>>n>>k;
   int a[n];
   for(int i=0;i<n;i++)
   {
    cin>>a[i];
   }
   if(n<=k)cout<<0;
   else
   {
    sort(a,a+n,greater<int>());
    for(int i=0;i<k;i++)
    {
      a[i]=0;
    }
    for(int i=0;i<n;i++)
    {
      sum+=a[i];
    }
    cout<<sum;
   }
 }

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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 998244353;

class Solution
{
private:
    int power(int base, int idx)
    {
        if (idx == 0)
            return 1;
        ll temp = power(base, idx / 2);
        temp = (temp * temp) % MOD;
        if (idx & 1)
            temp = (temp * base) % MOD;
        return temp;
    }

public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int n, s;
        cin >> n >> s;
        vector<int> a(n);
        for (size_t i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        const int LIM = 3001;
        vector<int> ways(LIM);
        ways[0] = 1;
        for (size_t j = 0; j < n; j++)
        {
            vector<int> newWays(LIM);
            for (size_t i = 0; i < LIM; i++)
                newWays[i] = (ways[i] * 2LL) % MOD;
            for (size_t i = a[j]; i < LIM; i++)
                newWays[i] = (newWays[i] + ways[i - a[j]]) % MOD;
            ways.swap(newWays);
        }
        cout << ways[s] << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 3704
# ALDS1_3_B: Queue
n, q = list(map(int, input().split()))
data = [input().split() for _ in range(n)]
total_time = 0
ends = []
for name, time in data:
    time = int(time)
    total_time += q if time - q > 0 else time
    time = time - q
    if time > 0:
        data.append([name, time])
        continue
    ends.append([name, total_time])

for name, time in ends:
    print(name, time)


Measured memory_bytes: 38572