akhauriyash/Code-Regression huggingface dataset:
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    a, b, c = LI()

    if not all([a % 2, b % 2, c % 2]):
        return 0

    tmp = sorted([a, b, c])
    return tmp[0] * tmp[1]


print(main())


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

int pi[233];

void jia(int k)
{
	if(k==pi[0])
	{
		if(pi[k]==9)
		{
			pi[++pi[0]]=1;
			pi[k]=0;
		}
		else pi[k]++;
		return;
	}
	pi[k]++;
	if(pi[k]-pi[k+1]>1||pi[k]==10)
	{
		jia(k+1);
		pi[k]=max(0,pi[k+1]-1);
	}
	return;
}

int main()
{
	int n; scanf("%d",&n);
	pi[0]=1;
	for(int i=1; i<=n; i++) jia(1);
	for(int i=pi[0]; i>0; i--) printf("%d",pi[i]);
	return 0;
}

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


using namespace std;

int dp[200][101];
int d, n, days[200], ans = 0;
struct cloth{
  int a, b, c;
};
cloth clothes[200];

int dfs(int day, int point){
  if(day == d)
    return 0;
  if(~dp[day][point])
    return dp[day][point];
  int res = 0;
  for(int i = 0; i < n; i++){
    if(clothes[i].a <= days[day] && days[day] <= clothes[i].b){
      res = max(res, abs(point - clothes[i].c)+ dfs(day + 1, clothes[i].c));
    }
  }
  return dp[day][point] = res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cin >> d >> n;
  for(int i = 0; i < d; i++){
    cin >> days[i];
  }
  for(int i = 0; i < n; i++){
    cin >> clothes[i].a >> clothes[i].b >> clothes[i].c;
  }
  memset(dp, -1, sizeof(dp));
  for(int i = 0; i < n; i++){
    if(clothes[i].a <= days[0] && days[0] <= clothes[i].b){
      ans = max(ans, dfs(1, clothes[i].c));
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 


ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}




bool compare(pi a,pi b)
{
     return (a.fi+a.se>b.fi+b.se);
}

int main()
{
    int n;
    cin>>n;
    vector<pi> vec(n);
    for(int i=0;i<n;i++)cin>>vec[i].fi>>vec[i].se;
    sort(vec.begin(),vec.end(),compare);
    ll res=0;
    for(int i=0;i<n;i++)
    {
         if(i%2==0)res+=vec[i].fi;
         else res-=vec[i].se;
    }
    cout<<res;
    
    
}















 














 
 

















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

int main() {
  ll a,b,x;
  cin >> a >> b >> x;
  ll ans;
  if (a == 0 && b == 0) {
    ans = 1; 
  } else if (a == 0){
    ans = b/x + 1;
  } else {
    ans = b/x - (a-1)/x;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
var
    n,m,q,i,j,k,x,y:longint;
    f,a:array[0..501,0..501] of longint;
begin
    readln(n,m,q);
    for i:=1 to m do
        begin
            readln(x,y);
            inc(a[x,y]);
        end;
    for i:=1 to n do
        for j:=i to n do
            begin 
                f[i,j]:=f[i,j-1];
                for k:=i to j do
                    f[i,j]:=f[i,j]+a[k,j];
            end;
    for i:=1 to q do
        begin
            readln(x,y);
            writeln(f[x,y]);
        end;
end.

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


int main()
{
  int a, b, c, d, x, y;

  cin >> a >> b >> c >> d;
  x = a+b;
  y = c+d;

  if ( x > y ) cout << "Left" << endl;
  else if ( x == y ) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
MOD = 10**9 + 7

a10 = 1
a9 = 1
a8 = 1
for i in range(n):
    a10 *= 10
    a10 %= MOD
    a9 *= 9
    a9 %= MOD
    a8 *= 8
    a8 %= MOD
a98 = 2 * a9 - a8
if a98 < 0: a98 += MOD
ans = a10 - a98
if ans < 0: ans += MOD
ans %= MOD
print(ans)

Measured memory_bytes: 9196
D, G = map(int, input().split())
pc = [[0, 0]] + [list(map(int, input().split())) for _ in range(D)]

min_kaisu = 999999999

for pattern in range(1 << D):
    score = 0
    kaisu = 0
    nokori_max = 0
    for i in range(1, D+1):
        if pattern & 1 << i-1:
            score += pc[i][0] * (i) * 100 + pc[i][1]
            kaisu += pc[i][0]
        else:
            nokori_max = i
    
    if score >= G:
        min_kaisu = min(min_kaisu, kaisu)
        continue
    
    if score + nokori_max * 100 * (pc[nokori_max][0] - 1) >= G:
        kaisu += -(-(G - score) // (nokori_max * 100))
        min_kaisu = min(min_kaisu, kaisu)
    else:
        continue
    
print(min_kaisu)

Measured memory_bytes: 40944
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

struct UnionFind {
    vector<int> par;
    vector<int> rank;

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); 
        rank.resize(n);
        for (int i = 0; i < n; i++) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) return x;
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        return true;
    }
};

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

    int data[n];
    rep(i,n){
        int p; cin >> p;
        data[p-1] = i;
    }

    UnionFind data2(n);
    rep(i,m){
        int x, y;
        cin >> x >> y;
        data2.merge(x-1,y-1);
    }

    int ans = 0;
    rep(i,n){
        if(data2.issame(i,data[i])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4568
// https://qiita.com/ytanto/items/caf7bf0ba287da81b20f

function main(input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if ((a * b) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 12
using namespace std;

int main() {
	int A, B, ans;
	cin >> A >> B;
	if (A > B)
		ans = A * 2 - 1;
	else if (A == B)
		ans = A * 2;
	else ans = B * 2 - 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353LL;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int n;
int ans;
ll d, x[N], y[N];

void solve()
{
    cin >> n >> d;
    d = d * d;
    for (int i = 1; i <= n;++i)
    {
        ll X, Y;
        cin >> X >> Y;
        if(X*X+Y*(Y)<=d)
            ans++;
    }
    cout << ans << '\n';
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

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

typedef long long ll;

const int Maxn = 5005;
const ll Inf = 1000000000000000000ll;

int n;
int A[Maxn];
vector <int> neigh[Maxn];
ll mn[Maxn][Maxn];
bool pos[Maxn][Maxn];
int cnt[Maxn];

void Solve(int v, int p = 0)
{
    fill(mn[v], mn[v] + Maxn, Inf);
    mn[v][0] = A[v]; pos[v][0] = A[v] > 0;
    cnt[v] = 1;
    for (int i = 0; i < neigh[v].size(); i++) {
        int u = neigh[v][i];
        if (u == p) continue;
        Solve(u, v);
        for (int j = cnt[v] - 1; j >= 0; j--) {
            bool po = pos[v][j]; pos[v][j] = false;
            ll my = mn[v][j]; mn[v][j] = Inf;
            for (int k = 0; k < cnt[u]; k++) {
                if (pos[u][k] || mn[u][k] < 0) {
                    pos[v][j + k + 1] |= po;
                    mn[v][j + k + 1] = min(mn[v][j + k + 1], my);
                }
                pos[v][j + k] |= (po & pos[u][k]);
                mn[v][j + k] = min(mn[v][j + k], my + mn[u][k]);
            }
        }
        cnt[v] += cnt[u];
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &A[i]);
    for (int i = 0; i < n - 1; i++) {
        int a, b; scanf("%d %d", &a, &b);
        neigh[a].push_back(b);
        neigh[b].push_back(a);
    }
    Solve(1);
    int res = 0;
    while (!pos[1][res] && mn[1][res] >= 0) res++;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 221056
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 1e9;
    for (int i = 0; i + 3 <= s.size(); i++) {
        int v = stoi(s.substr(i, 3));
        ans = min(ans, abs(v - 753));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
C=[0]*N

for i in range(N):
    B[i]=A[i]+i
    C[i]=i-A[i]

B.sort()
B.insert(0,-2000000000)
B.append(2000000000)
C.sort()
ans=0
for a in C:
    l1=0
    r1=N
    while r1-l1>1:
        m1=(l1+r1)//2
        if B[m1] < a:
            l1=m1
        else:
            r1=m1
    l2=0
    r2=N
    while r2-l2>1:
        m2=(l2+r2)//2
        if B[m2] <= a:
            l2=m2
        else:
            r2=m2
    ans += l2-l1

print(ans)

Measured memory_bytes: 93040
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< string > S(N);
	rep(i, N) cin >> S[i];
	map< string, int > M;
	rep(i, N) M[S[i]]++;
	int max = 0;
	for (auto p : M) {
		if (p.second > max) {
			max = p.second;
		}
	}
	vector< string > ans;
	for (auto p : M) {
		if (p.second == max)
			ans.push_back(p.first);
	}
	sort(ans.begin(), ans.end());
	rep(i, ans.size()) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 28404
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  var a, b int

  sc.Scan()
  a, _ = strconv.Atoi(sc.Text())

  for i := 1; i < 5; i++ {
    sc.Scan()
    b, _ = strconv.Atoi(sc.Text())
  }

  sc.Scan()
  k, _ := strconv.Atoi(sc.Text())

  if b - a > k {
    fmt.Println(":(")
  } else {
    fmt.Println("Yay!")
  }
}





Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll otaku,kimo,kimootaku;cin>>otaku;kimo=0;kimootaku=otaku;
  kimo+=otaku/100000000;otaku%=100000000;
  kimo+=otaku/10000000;otaku%=10000000;
  kimo+=otaku/1000000;otaku%=1000000;
  kimo+=otaku/100000;otaku%=100000;
  kimo+=otaku/10000;otaku%=10000;
  kimo+=otaku/1000;otaku%=1000;
  kimo+=otaku/100;otaku%=100;
  kimo+=otaku/10;otaku%=10;
  kimo+=otaku/1;
  //output
  cout<<((kimootaku%kimo)?"No":"Yes")<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			int[] a = new int[n];
			int[] v = new int[n];
			int[] w = new int[n];
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt();
				v[i] = sc.nextInt();
			}
			
			w = Arrays.copyOf(v, n);
			Arrays.sort(w);
			int min = Integer.MAX_VALUE;
			
			for(int i=0;i<n;i++){
				if(v[i]==w[n-1]){
					min = Math.min(min, a[i]);
				}
			}
			
			System.out.println(min + " " + w[n-1]);
		}
	}	
}

Measured memory_bytes: 17340
def main():
    line = input()
    line = line.split(' ')
    n = int(line[0])
    t = int(line[1])
    line = input()
    line = line.split(' ')
    total = 0
    for i in range(1, n):
        total += min(t, int(line[i]) - int(line[i - 1]))
    print(total+t)


if __name__ == '__main__':
    main()

Measured memory_bytes: 19220
using System;

class P
{
public static void Main()
{
            bool y = true;
            int z;

            while (y)
            {
                //????????????????????????
                var x = Console.ReadLine().Split(' ');

                //??????????????????
                int a = Int32.Parse(x[0]);
                int b = Int32.Parse(x[2]);
                string op = x[1];

                if (op == "+") 
                { 
                    z = a + b;
                    Console.WriteLine(z.ToString());
                }
                else if (op == "-")
                {
                    z = a - b;
                    Console.WriteLine(z.ToString());
                }
                else if (op == "*")
                {
                    z = a * b;
                    Console.WriteLine(z.ToString());
                }
                else if (op == "/")
                {
                    z = a / b;
                    Console.WriteLine(z.ToString());
                }
                else
                {
                    y = false;
                }
            }
}
}

Measured memory_bytes: 9144
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    int i = 0;
    char before = 'A';
    while(i < n){
        if(s[i] != before){
            ans++;
            before = s[i];
            i++;
        }
        else {
            if(i != n-1){
                ans++;
                before = 'A';
                i += 2;
            }
            else{
                break;
            }

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,m;
  cin >> n >> m;
  LL mi = -1;
  LL ma = 10000000000;
  REP(i,m) {
    LL l,r;
    cin >> l >> r;
    mi=max(l,mi);
    ma=min(r,ma);
  }
  LL answer = ma-mi+1;
  answer = max(answer,0ll);
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		char[][]c=new char[H][W];
		for(int i=0;i<H;i++){
			String x=sc.next();
			for(int j=0;j<W;j++){
				c[i][j]=x.charAt(j);
			}
		}long g[][]=new long[H+1][W+1];
		int i;int j=0;
		for( i=0;i<=H;i++){
			for(j=0;j<=W;j++){
				if(i==0||j==0){
					g[i][j]=0;
				}else{
					if(i==1&&j==1){
						g[i][j]=1;
					}else{
						if(c[i-1][j-1]=='#'){
							g[i][j]=0;
						}else{
							g[i][j]=(g[i-1][j]+g[i][j-1])%1000000007;
						}
					}
				}
			}
		}System.out.print(g[i-1][j-1]%1000000007);
	}
}

Measured memory_bytes: 40940
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    ull ans = 0;
    for (int i = 1; i < n; i++)
        for (int j = 1; j * i < n; j++)
            ans++;
    cout << ans << '\n';
    return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> a(N);
	vector<ll> d(N + 1, 0);
	vector<ll> wl(N + 1, 0);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		d[i + 1] = d[i] + a[i];
		if (a[i] > 0) { wl[i + 1] += a[i]; }
		wl[i + 1] += wl[i];
	}

	ll res = 0;
	for (int i = 0; i <= N - K; ++i) {
		ll tmp = max(0LL, d[i + K] - d[i]);
		tmp += (wl[i] + (wl[N] - wl[i + K]));
		res = max(res, tmp);
	}

	cout << res << endl;

	return 0;
}


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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve() {
    int N, C;
    cin >> N >> C;

    vector<vecl> d(C,vecl(C));
    for (int i = 0; i < C; ++i)
        for (int j = 0; j < C; ++j)
            cin >> d[i][j];
    
    int color;
    vector<map<int,int>> types(3);
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> color;
            types[(i+j)%3][color-1] += 1;
        }
    }

    ll ans = 1e18;
    for (int i=0; i<C; ++i) {
        for (int j=0; j<C; ++j) {
            if (i==j)   continue;
            for (int k=0; k<C; ++k) {
                if (i==k || j==k)   continue;
                ll v = 0;
                for (auto e:types[0])
                    v += d[e.fi][i]*e.se;
                for (auto e:types[1])
                    v += d[e.fi][j]*e.se;
                for (auto e:types[2])
                    v += d[e.fi][k]*e.se;
                
                ans = min(ans,v);
            }
        }
    }

    cout << ans << endl;
}


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
    solve();
}



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

using namespace std;

int main() {

    int N, M;
    cin >> N >> M;
    vector<array<vector<pair<int, int>>, 3>> nodes(N);
    for (int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        nodes[u - 1][0].push_back(make_pair(v - 1, 1));
        nodes[u - 1][1].push_back(make_pair(v - 1, 2));
        nodes[u - 1][2].push_back(make_pair(v - 1, 0));
    }

    vector<array<int, 3>> memo(N, { -1,-1,-1 });

    int S, T;
    cin >> S >> T;

    queue<pair<int, int>> q;
    q.push(make_pair(S - 1, 0));
    memo[S - 1][0] = 0;
    while (!q.empty()) {
        pair<int, int> now = q.front();
        q.pop();
        for (auto& next : nodes[now.first][now.second]) {
            if (memo[next.first][next.second] != -1)continue;
            memo[next.first][next.second] = memo[now.first][now.second] + 1;
            q.push(next);
        }
    }
    int ans = memo[T - 1][0];
    if (ans != -1)ans /= 3;
    cout << ans << endl;
}

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

using namespace std;

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


int main(){
 int h,w;
  cin >> h >> w;
  string s[h];
  for(int i=0;i<h;i++) cin >> s[i];
  
  for(int i=0;i<h;i++){
   for(int j=0;j<w;j++){
    if(s[i][j]=='#') continue;
     
     int cnt=0;
     for(int k=0;k<8;k++){
     int nx=j+dx[k]; 
     int ny=i+dy[k];
       if(nx<0||w-1<nx||ny<0||h-1<ny) continue;
       if(s[ny][nx]=='#')cnt++;
     }
     s[i][j]=char(cnt+'0');
   }
  }
  for(int i=0;i<h;i++) cout << s[i] << endl;
  
}

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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    string S;
    long MARCH[5] = {0};

    for (int i = 0; i < N; i++) {
        cin >> S;
        switch(S[0]) {
            case 'M':
                MARCH[0]++;
                break;
            case 'A':
                MARCH[1]++;
                break;
            case 'R':
                MARCH[2]++;
                break;
            case 'C':
                MARCH[3]++;
                break;
            case 'H':
                MARCH[4]++;
                break;
        }
    }

    long count = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                // cout << i << j << k << endl;
                count += MARCH[i] * MARCH[j] * MARCH[k];
            }
        }
    }
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = read().rstrip().decode()
memo = s[0]
cnt = 0
for check in s[1:]:
    if memo != check:
        memo = check
        cnt += 1
print(cnt)


Measured memory_bytes: 3316
main :: IO ()
main = do
  n <- readLn
  print $ g n

f :: Int -> [(Int,Int)]
f n = [(x, n-x) | x <- [1..(n `div` 2)]]

sod
  :: Int -> Int
sod = sum . sod'

sod' 
  :: Int -> [Int]
sod' n
  | q == 0 = [r] 
  | otherwise = r : sod' q
  where
    (q,r) = quotRem n 10

sod2 :: Int -> Int -> Int
sod2 x y = sod x + sod y

g :: Int -> Int
g = minimum . map (uncurry sod2) . f


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, cnt;

int main()
{
    cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
        if (p[i] != i + 1)
            cnt++;
    }
    if (cnt == 0 || cnt == 2)
        puts("YES");
    else
        puts("NO");
}

Measured memory_bytes: 256
/*
  Code By RyeCatcher
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>
#include <cmath>
#include <utility>
#define ri register int
#define ll long long
#define ull unsigned long long
#define pb push_back
#define DEBUG freopen("dat.in","r",stdin);freopen("wa.out","w".stdout);
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
using std::min;
using std::max;
using std::pair;
using std::queue;
using std::priority_queue;
using std::vector;
#define gc getchar
template <class T>inline void read(T &x){
	x=0;int ne=0;char c;
    while((c=gc())>'9'||c<'0')ne=c=='-';x=c-48;
    while((c=gc())>='0'&&c<='9')x=(x<<3)+(x<<1)+c-48;x=ne?-x:x;return ;
}
const int maxn=100155;
const int size=100150;
const int inf=0x7fffffff;
const ll P=1e9+7;
int n,m;
int c[maxn],tot=0;
ll fac[maxn],inv_fac[maxn];
ll C(int n,int m){
	return fac[m]*inv_fac[n]%P*inv_fac[m-n]%P;
}
ll ksm(ll a){
	ll ans=1;
	ll c=P-2;
	while(c){
		if(c&1)ans=ans*a%P;
		a=a*a%P;
		c=c>>1;
	}
	return ans%P;
}
int main(){
	int x,y,M;
	read(n),read(m);
	M=m;
	for(ri i=2;i*i<=M;i++){
		if(M%i==0){
			c[++tot]=1;
			M/=i;
			while(M%i==0){M/=i;c[tot]++;}
		}
	}
	if(M>1)c[++tot]=1;
	fac[0]=fac[1]=1;
	for(ri i=2;i<=size;i++)
		fac[i]=fac[i-1]*i%P;
	inv_fac[size]=ksm(fac[size]);
	for(ri i=size-1;i>=0;i--)
		inv_fac[i]=inv_fac[i+1]*1ll*(i+1)%P;
	ll ans=1;
	for(ri i=1;i<=tot;i++){
		ans=ans*C(n-1,n+c[i]-1)%P;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


//ABC061_b
int main() {
	int N, M;
	cin >> N >> M;

	vector<int> A(2*M);
	vector<int> ans(N);

	rep(i, 2*M) {
		cin >> A.at(i);
	}

	rep(i, 2*M) {
		ans.at(A.at(i)-1) += 1;
	}

	rep(i, N) {
		cout << ans.at(i) << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

bitset<4000001> bset, _bset;

int main() {
	int N; cin >> N;
	
	bset.reset();
	_bset.reset();

	int sum = 0;
	bset[0] = true;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		sum += a;

		_bset = bset << a;
		bset |= _bset;
	}

	for (int k = (sum + 1) / 2; k <= sum; k++) {
		if (bset[k] == true) {
			cout << k << endl;
			return 0;
		}
	}


	return 0;
}

Measured memory_bytes: 2176
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(System.out);

    int r = sc.nextInt();
    int c = sc.nextInt();

    int[][] table = new int[r+1][c+1];
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            table[i][j] = sc.nextInt();
        }
        table[i][c] = IntStream.of(table[i]).sum();
    }

    for (int i = 0; i <= c; i++) {
      for (int j = 0; j < r; j++) {
        table[r][i] += table[j][i];
      }
    }

    for (int[] row : table) {
        String str = "";
        for (int cell : row) {
            str += cell + " ";
        }
        pw.println(str.trim());
    }

    pw.flush();
    sc.close();
  }
}


Measured memory_bytes: 57192
#include <bits/stdc++.h>
#define F(i, a, b) for (int i = (a); i < (b); ++i)
#define F2(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i > (b); --i)
#define dF2(i, a, b) for (int i = (a); i >= (b); --i)
#define maxn 1010
using namespace std;
typedef long long LL;
int d1[maxn], d2[maxn], tot1, tot2, tot, n, a[maxn];
int* d;
vector<int> ans;
void solve() {
//    printf("%d\n", tot);
//    F(i, 0, tot) printf("%d ", d[i]);
    F(i, 1, d[0]) ans.push_back(1);
    dF(i, n, d[tot-1]) ans.push_back(i-d[0]+1);
    F2(i, 1, tot-1) {
        int lim=(d[i]-d[i-1])>>1;
        dF(j, 1+lim, 1) ans.push_back(j);
    }
}
int main() {
    scanf("%d", &n);
    int p=1;
    F2(i, 1 ,n) {
        scanf("%d", &a[i]);
        p = a[i] > a[p] ? i : p;
    }
    LL sum;
    if (a[p]<=0) d1[tot++]=p, sum=a[p], d=d1;
    else {
        LL sum1=0, sum2=0;
        for (int i = 1; i <= n; i += 2) if (a[i]>0) d1[tot1++]=i, sum1+=a[i];
        for (int i = 2; i <= n; i += 2) if (a[i]>0) d2[tot2++]=i, sum2+=a[i];
        d = sum1 < sum2 ? d2 : d1;
        tot = sum1 < sum2 ? tot2 : tot1;
        sum = max(sum1, sum2);
    }
    solve();
    printf("%lld\n%d\n", sum, ans.size());
    for (auto x : ans) printf("%d\n", x);
    return 0;
}


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

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  if(c-b-a>0&&4*a*b<(c-b-a)*(c-b-a)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
let () =
  let n1 = read_int () and
      n2 = read_int () and
      n3 = read_int () and
      n4 = read_int () and
      n5 = read_int () in
  let n = if n1 > n2 then n2 else n1 in
  let pasta = if n > n3 then n3 else n and
      juice = if n4 > n5 then n5 else n4 in
  Printf.printf "%d\n" (pasta+juice-50)
;;

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

using namespace std;
typedef long long LL;
LL a[1000000];
int main(){
	LL n;
	cin>>n;
	LL S=0;
	for(LL i=1;i<=n;i++){
		cin>>a[i];
		S+=a[i];
	} 
	sort(a+1,a+n+1); 
	S=-a[1]+a[n];
	for(LL i=2;i<n;i++) S+=abs(a[i]);
	cout<<S<<endl;
	vector<LL> X,Y;
	X.push_back(a[n]);
	Y.push_back(a[1]);
	for(LL i=2;i<n;i++){
		if(a[i]>=0) X.push_back(a[i]);
		else Y.push_back(a[i]);
	} 
	LL now=X[0];
	LL now1;
	for(LL i=0;i<(LL)Y.size()-1;i++){
		 cout<<now<<' '<<Y[i]<<endl;
		 now=now-Y[i];
	}
	now1=Y.back();
	for(LL i=1;i<(LL)X.size();i++){
		cout<<now1<<' '<<X[i]<<endl;
		now1=now1-X[i];
	}
	cout<<now<<' '<<now1<<endl;
	return 0;
}


Measured memory_bytes: 3572
#include <stdio.h>

int main(void)
{
	int a, b;
	int ans;
	scanf("%d %d", &a, &b);
	if(a > 9 || b > 9) {
		ans = -1;
	} else {
		ans = a * b;
	}
	printf("%d\n", ans);
}



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

using i64 = long long;

const int N = 100;

int w, b;
char wc, bc;

char mx[N + 5][N + 5];

int main() {
#ifdef HOME
	freopen("arc.in", "r", stdin);
	freopen("arc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	wc = '.';
	bc = '#';

	cin >> w >> b;
	if (w > b) {
		swap(w, b);
		swap(wc, bc); }
	w-= 1;

	for (int i = 0; i < N; ++i)
	for (int j = 0; j < N; ++j)
		mx[i][j] = wc;

	for (int i = 0; i + 2 < N; i+= 4)
	for (int j = 0; j + 2 < N; j+= 4) if (b > 0) {
		for (int x = 0; x < 3; ++x)
		for (int y = 0; y < 3; ++y)
			mx[i + x][j + y] = bc;

		b-= 1;
		if (w > 0) {
			mx[i + 1][j + 1] = wc;
			w-= 1; } }

	cout << N << ' ' << N << '\n';
	for (int i = 0; i < N; ++i)
		cout << mx[i] << '\n';

	return 0; }


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int S,h,m,s;
    scanf("%d" ,&S);
    h=S/3600;
    m=(S-h*3600)/60;
    s=(S-(h*3600+m*60));
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 592
var a,c,d,e,f,g,gg : int64;
    cc,so : string ;
     b : longint;
begin
 readln(cc);
 a:=1;
 while cc[a]<>' ' do
  begin
   so:=so+cc[a];
   a:=a+1;
  end;
 val(so,f);
 a:=a+1;
 if cc[a]='+' then
  gg:=1;
 if cc[a]='-' then
  gg:=2;
 a:=a+2;
 so:='';
 for b:=a to length(cc) do
  so:=so+cc[b];
 val(so,g);
 if gg=1 then
  writeln(f+g)
 else if gg=2 then
  writeln(f-g);
end.

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

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int pedras[n], pd[n];
    for (int i=0; i<n; i++){
        int aux;
        cin >> aux;
        pedras[i] = aux;
        pd[i] = INT_MAX;
    }
    pd[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=1; j<=k && i+j<n ; j++){
            pd[i+j] = min(pd[i+j],pd[i] + abs(pedras[i]-pedras[i+j]));
        }
    }
    cout << pd[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
    cout << a*b << endl;
  }
  else cout << -1 << endl;
}

Measured memory_bytes: 256
import math
def main():
    K = int(input())
    mae = []
    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            mae.append(math.gcd(i,j))
    for m in mae:
        for k in range(1, K+1):
            ans += math.gcd(m, k)
    print(ans)
main()

Measured memory_bytes: 69908
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

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

  V<int> can = {1};
  ll t = 1;
  while (true) {
    t *= 6;
    if (t > n) break;
    can.push_back(t);
  }
  t = 1;
  while (true) {
    t *= 9;
    if (t > n) break;
    can.push_back(t);
  }

  V<int> dp(n + 1, n);
  dp[0] = 0;
  rep(i, n) {
    for (auto c : can) {
      if (i + c > n) continue;
      dp[i + c] = min(dp[i] + 1, dp[i + c]);
    }
  }

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


Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
struct node
{
	node *l,*r;
	node():l(NULL),r(NULL){}
};
string Tree[2];
void string_to_tree(int n,node *cur,int l,int r)
{
	int cnt=0,f;
	for(int i=l+1;i<r;i++)
	{
		if(Tree[n][i]=='(')cnt++;
		if(Tree[n][i]==')')cnt--;
		if(Tree[n][i]==','&&cnt==0)
		{
			f=i;
			break;
		}
	}
	if(Tree[n][f-1]=='('&&Tree[n][f+1]==')')return;
	if(Tree[n][f+1]==')')
	{
		cur->l = new node();
		string_to_tree(n,cur->l,l+1,f-1);
	}
	else if(Tree[n][f-1]=='(')
	{
		cur->r = new node();
		string_to_tree(n,cur->r,f+1,r-1);
	}
	else
	{
		cur->l = new node();
		cur->r = new node();
		string_to_tree(n,cur->l,l+1,f-1);
		string_to_tree(n,cur->r,f+1,r-1);
	}
	return;
}
node *root[2];
node *ans; 
node *tmp;
string Ans;
void tree_to_string(node *cur)
{
	if(cur==NULL)return;
	Ans+='(';
	tree_to_string(cur->l);
	Ans+=',';
	tree_to_string(cur->r);
	Ans+=')';
	return;
}
void unite(node *cur,node *c1,node *c2)
{
	if((c1->l)!=NULL&&(c2->l)==NULL)
	{
		cur->l = new node();
		unite(cur->l,c1->l,tmp);
	}
	else if((c1->l)==NULL&&(c2->l)!=NULL)
	{
		cur->l = new node();
		unite(cur->l,tmp,c2->l);
	}
	else if((c1->l)!=NULL&&(c2->l)!=NULL)
	{
		cur->l = new node();
		unite(cur->l,c1->l,c2->l);
	}
	if((c1->r)!=NULL&&(c2->r)==NULL)
	{
		cur->r = new node();
		unite(cur->r,c1->r,tmp);
	}
	else if((c1->r)==NULL&&(c2->r)!=NULL)
	{
		cur->r = new node();
		unite(cur->r,tmp,c2->r);
	}
	else if((c1->r)!=NULL&&(c2->r)!=NULL)
	{
		cur->r = new node();
		unite(cur->r,c1->r,c2->r);
	}
	return;
}
void intersect(node *cur,node *c1,node *c2)
{
	if((c1->l)!=NULL&&(c2->l)!=NULL)
	{
		cur->l = new node();
		intersect(cur->l,c1->l,c2->l);
	}
	if((c1->r)!=NULL&&(c2->r)!=NULL)
	{
		cur->r = new node();
		intersect(cur->r,c1->r,c2->r);
	}
	return;
}
int main()
{
	string op;
	tmp = new node();
	while(cin >> op >> Tree[0] >> Tree[1])
	{
		Ans.clear();
		root[0] = new node();
		root[1] = new node();
		ans = new node();
		string_to_tree(0,root[0],0,((int)Tree[0].size())-1);
		string_to_tree(1,root[1],0,((int)Tree[1].size())-1);
		if(op=="u")unite(ans,root[0],root[1]);
		else intersect(ans,root[0],root[1]);
		tree_to_string(ans);
		cout << Ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <string>

using namespace std;
using tu = tuple<int, string,int>;

vector<tu> N;

int main(int argc, const char** argv) {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        string s;
        int p;
        cin >> s >> p; 
        N.push_back(make_tuple(i+1, s, p));
    } 
sort(N.begin(),N.end(), [](tu const &lhs, tu const &rhs) {
    string s1 = get<1>(lhs);
    string s2 = get<1>(rhs);
    if (s1 != s2) return s1 < s2;
    int p1 = get<2>(lhs);
    int p2 = get<2>(rhs);
    return p1 > p2;
});
for (auto t: N) {
    cout << get<0>(t) << endl;
}
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())

s=[]
s.append(['.' for i in range(w+2)])
for i in range(h):
    ss = list('.' + input() + '.')
    s.append(ss)
s.append(['.' for i in range(w+2)])

for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == '#' and s[i][j-1] == '.' and s[i][j+1] == '.' and s[i-1][j] == '.' and s[i+1][j] == '.':
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)

ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}


int main(){
	
	string s,t;
	cin>>s>>t;
	ll n = s.size();
	ll sz = t.size();
	ll ans = inf;
	rep(i,0,n){
		
		if(i+sz<=n){
		ll k = 0;
		ll su = 0;
		rep(j,i,i+sz){
		
			if(s[j]!=t[k]) su++;
			k++;
		}
		
		ans = min(ans,su);}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3624
import java.util.*;
import java.io.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    double value = Math.log(h) / Math.log(2.0);
    int pow = (int) value + 1;
    long ans = (long)Math.pow(2, (double)pow) - (long)1;
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
import numpy as np
alp = [chr(v) for v in range(ord("a"), ord("z") + 1)]
inp = input()

if inp[::-1] == "".join(alp):
    print(-1)
    exit()

if len(inp) == len(alp):
    prev = inp[0]
    indices = [0]
    for index, char in enumerate(inp[1:]):
        if prev < char:
            indices.append(index)
        prev = char
    # diff = [0] * (len(indices) - 1)
    # for i, (v1, v2) in enumerate(zip(indices[1:], indices[:-1])):
    #     diff[i] = v1 - v2
    # maxv = float("-inf")
    # maxv_index = 0
    # for i, d in enumerate(diff):
    #     if maxv <= d:
    #         maxv = d
    #         maxv_index = i
    #
    # index = indices[maxv_index + 1]
    index = indices[-1]
    targets = inp[index + 1:]
    for v in sorted(targets):
        if inp[index] < v:
            break
    print(inp[:index] + v)

else:
    print(inp + min(set(alp) - set(list(inp))))


Measured memory_bytes: 21144
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

string S[2100];
long long int ans[2100][2100] = {};

int main(){
    int H, W;
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        cin >> S[i];
    }
    for(int i = 0; i < H; i++){
        int cnt = 0;
        for(int j = 0; j < W; j++){
            ans[i][j] += cnt;
            if(S[i][j] == '.'){
                cnt += 1;
            }else{
                cnt = 0;
            }
        }
        cnt = 0;
        for(int j = W - 1; j >= 0; j--){
            ans[i][j] += cnt;
            if(S[i][j] == '.'){
                cnt += 1;
            }else{
                cnt = 0;
            }
        }
    }
    for(int j = 0; j < W; j++){
        int cnt = 0;
        for(int i = 0; i < H; i++){
            ans[i][j] += cnt;
            if(S[i][j] == '.'){
                cnt += 1;
            }else{
                cnt = 0;
            }
        }
        cnt = 0;
        for(int i = H - 1; i >= 0; i--){
            ans[i][j] += cnt;
            if(S[i][j] == '.'){
                cnt += 1;
            }else{
                cnt = 0;
            }
        }
    }
    long long int A = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(S[i][j] == '.'){
                A = max(A, 1 + ans[i][j]);
            }
        }
    }
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 37120
#include <bits/stdc++.h>
using namespace std;
int ans[505][505];
void check(int n,int k){
    vector<pair<int,int>>bl[1005];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            bl[ans[i][j]].emplace_back(i,j);
    for(int i=1;i<=k;i++){
        multiset<int>qwq;
        for(auto pos:bl[i]){
            int x,y;tie(x,y)=pos;
            multiset<int>cur;
            cur.insert(ans[x][y==1?n:y-1]);
            cur.insert(ans[x][y==n?1:y+1]);
            cur.insert(ans[x==1?n:x-1][y]);
            cur.insert(ans[x==n?1:x+1][y]);
            if(qwq.size()==0)qwq=cur;
            else if(qwq!=cur){
                cout<<"col:"<<i<<"\n";
                cout<<x<<" "<<y<<"\n";
                for(int i:qwq)cout<<i<<" ";cout<<"\n";
                for(int i:cur)cout<<i<<" ";cout<<"\n";
                exit(0);
            }
        }
    }
    puts("success");
}
int main(){
    int n,k;cin>>k;
    if(k<=500){
        n=k;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                ans[i][j]=i;
    }else{
        n=500;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                ans[i][j]=((i+j)%n)+1;
        for(int i=2;i<=n+n;i++){
            for(int x=1;x<=n;x++){
                static int chk[1005];
                int y=i-x;
                if(y<1||y>n)continue;
                int v=ans[x][y];
                if(v+n>k)continue;
                ans[x][y]+=n*chk[v];
                chk[v]^=1;
            }
        }
    }
    cout<<n<<"\n";
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cout<<ans[i][j]<<" \n"[j==n];
    return 0;
}

Measured memory_bytes: 2176
import math

class _const:
    def __init__(self):
        self.PI=math.acos(-1)
        self.convToDEG=180/self.PI
const=_const()


a,b,x=map(int,input().split(" "))

Volume=a*a*b

if 2*x>=Volume:
    print(const.convToDEG*math.atan(2*(a*a*b-x)/a**3))

else:
    r=2*x/(a*b*b)

    print(const.convToDEG*(const.PI/2-math.atan(r)))
        



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n;
pair<int,int> p[100010];
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>p[i].first;
	for (int i=0;i<n;i++) p[i].second=i;
	sort(p,p+n);
	for (int i=0;i<n;i++) cout<<p[i].second+1<<' ';
	return 0;
}

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



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int l, r, d;
	cin >> l >> r >> d;
	cout << r / d - (l - 1) / d;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int N,M,R;
int r[8];
int d[205][205];
int ans;
int per[8];
int used[8];

void warshall_floyd(){
	int i,j,k;

	for(k=1;k<=N;k++){
		for(i=1;i<=N;i++){
			for(j=1;j<=N;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}

}

void dfs(int depth){

	int i;

	if(depth==R){


		int cost=0;

		for(i=0;i<R-1;i++){
			int from=r[per[i]-1];
			int to=r[per[i+1]-1];
			cost+=d[from][to];
		}

		if(ans>cost){ans=cost;}

		return ;
	}

	for(i=0;i<R;i++){

	if(used[i]==0){
		per[depth]=i+1;
		used[i]=1;
		dfs(depth+1);
		used[i]=0;
		}
	}
}

int main(){

	scanf("%d %d %d",&N,&M,&R);

	int i,j;

	for(i=1;i<=N;i++){
		for(j=1;j<=N;j++){
			if(i==j){d[i][j]=0;}
			else{d[i][j]=1<<25;}
		}
	}


	for(i=0;i<R;i++){
		scanf(" %d",&r[i]);
	}
	for(i=0;i<M;i++){
		int A,B,C;
		scanf("%d %d %d",&A,&B,&C);
		d[A][B]=C;
		d[B][A]=C;
	}

	warshall_floyd();

	ans=1<<30;

	dfs(0);

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

	return 0;
}

Measured memory_bytes: 384