akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main{
    static int[] joi;
    static int[][] F;
    static int max;
    static int N;
    static int[][] P;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        N = sc.nextInt();
        F = new int[N][10];
        for(int i = 0; i < N; i++){
            for(int j = 0; j < 10; j++){
                F[i][j] = sc.nextInt();
            }
        }
        P = new int[N][11];
        for(int i = 0; i < N; i++){
            for(int j = 0; j < 11; j++){
                P[i][j] = sc.nextInt();
            }
        }
        sc.close();
        joi = new int[10];
        max = Integer.MIN_VALUE;
        dps(0);
        System.out.println(max);
    }
    static void dps(int pos){
        if(pos == 10 && !(isEmpty())){
            int sum = 0;
            for(int i = 0; i < N; i++){
                sum += P[i][count(i)];
            }
            max = Math.max(max, sum); 
        }
        if(pos < 10){
            joi[pos] = 0;
            dps(pos+1);
            joi[pos] = 1;
            dps(pos+1);
        }
    }

    static boolean isEmpty(){
        for(int i = 0; i < 10; i++){
            if(joi[i] != 0)
                return false;
        }
        return true;
    }

    static int count(int n){
        int count = 0;
        for(int i = 0; i < 10; i++){
            if(joi[i] == 1 && F[n][i] == 1)
                count++;
        }
        return count;
    }
}

Measured memory_bytes: 26260
#include <iostream>
#include <vector>
using namespace std;
template<typename T> void chmin(T& a,const T& b) {
   if(a > b) {
      a = b;
   }
}
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    vector<int>dp(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        dp[i] = 1e9;
    }
    dp[0] = 0;
    for(int i=1; i<n; i++){
        chmin(dp[i], dp[i-1] + abs(a[i] - a[i-1]));
        if(i>1){
            chmin(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4052
from collections import deque

tmp = input().split()
N = int(tmp[0])
M = int(tmp[1])
ve = [deque() for _ in range(N)]
todo = deque()

s = 0
for m in range(M):
    S, T  = map(int,input().split())
    ve[S-1].append(T)
    ve[T-1].append(S)

visited = [False]*N
dist = [0]*N
todo.append(1)
   
while len(todo)>0:
    now = todo.popleft()   
    while len(ve[now-1])>0:
        sr = ve[now-1].pop()
        if  visited[sr-1]: continue
        dist[sr-1] = now
        visited[sr-1] = True
        todo.append(sr)

print('Yes')
[print(i) for i in dist[1:]]






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

using namespace std;

int main() {
    /* code */
    int N = 0;
    cin >> N;
    int ans = 100000;
    int A, B, C, D, E;
    int temp = 0;
    for (size_t i = 1; i < 1+N/2; i++)
    {
        temp = 0;
        A = i;
        B = N - i;
        while (A!=0)
        {
            temp += A%10;
            A /= 10;
        }while (B!=0)
        {
            temp += B%10;
            B /= 10;
        }
        //cout << temp << endl;
        if(ans > temp){
            ans = temp;
        }
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3624
n=input()
p=input()

n=n.split()
n=int(n[0])
p=p.split()
p=[int(p) for p in p]

output=0
for i in range(n-2):
    if p[i]<p[i+1] and p[i+1]<p[i+2]:
        output=output+1
    elif p[i+2]<p[i+1] and p[i+1]<p[i]:
        output=output+1
    else:
        output=output+0
    
print(output)

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

using namespace std;

char MapData[100][100];
bool Finished;
int N;

bool check(int x, int y, int i) {
	 
	if (i == 0 || i==2) {
		if (MapData[y][x-1] == ' ' && MapData[y][x+1] == ' ') {
			return true;
		}
	}
	else if (i == 1 || i==3) {
		if (MapData[y-1][x] == ' ' && MapData[y+1][x] == ' ') {
			return true;
		}
	}
	return false;
}

void solve(int x, int y, int direction) {
	int dx[] = { 0,2,0,-2 };
	int dy[] = { -2,0,2,0 };
	int currentX, currentY, i, cnt;

	cnt = 0;
	for (i = direction; cnt < 4; i++) {
		currentX = x + dx[i%4];
		currentY = y + dy[i%4];
		if (currentX<0 || currentX>N-1 || currentY<0 || currentY>N-1) {
			continue;
		}
		if (MapData[currentY][currentX] == ' ') {
			switch (i%4)
			{
			case 0:currentY++; break;
			case 1:currentX--; break;
			case 2:currentY--; break;
			case 3:currentX++; break;
			}
			if (MapData[currentY][currentX] == ' ' && check(currentX, currentY, i%4)) {
				MapData[currentY][currentX] = '#';
				solve(currentX, currentY,i%4);
			}
		}
		if (Finished) {
			return;
		}
		cnt++;
	}
	if (cnt == 4) {
		Finished = true;
	}
}

int main() {
	int d;

	cin >> d;
	while (d--) {
		cin >> N;

		memset(MapData, ' ', sizeof(MapData));
		Finished = false;
		for (int i = 0; i < N; i++) {
			MapData[0][i] = '#';
			MapData[i][0] = MapData[i][N - 1] = '#';
			MapData[N - 1][i] = '#';
		}
		if (N > 1) {
			MapData[N - 1][1] = ' ';
		}
		if (N > 4) {
			solve(2, N - 1, 0);
		}


		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				cout << MapData[i][j];
			}
			cout << endl;
		}
		if (d != 0) {
			cout << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3360
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	int a[n];
	forn(i,0,n) cin>>a[i];
	
	int Min=1e9;
	int ans=0;
	forn(i,0,n){
		if(a[i]<Min) ans++;
		Min=min(Min,a[i]);
	}
	cout<<ans<<'\n';
	
	return 0;
}


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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007



int main() {
    string s, t, u; cin >> s >> t;
    u = s + s;
    ll x = s.size(), y = t.size();
    vll hu[26];
    rep(i,2*x){
        int j = u[i] -'a';
        hu[j].pb(i);
    }

    vector<vll> next(x, vll(26, -1));
    //next[i][j]はsのi番目(0-origin)以降(i含む)でjが初めて出てくる場所
    rep(i, x) {
        rep(j, 26) {
            if(hu[j].empty()) continue;
            ll c = *lower_bound(all(hu[j]),i);
            next[i][j] = c % x;
        }
    }

    ll ans = 0;
    vll So(100005, -1); //greedyにtのi番目に対応してsの文字の出現場所を列挙
    bool f = true;

    rep(i, y) {
        int j = t[i] - 'a';
        So[i + 1] = next[(So[i] + 1) % x][j];
        if (So[i + 1] == -1) {
            f = false;
            break;
        }
        ll tmp = (So[i + 1] > So[i] ?
                  So[i + 1] - So[i] :
                  So[i + 1] - So[i] + x);
        ans = ans + tmp;
    }

    cout << (f ? ans : -1) << endl;

}


Measured memory_bytes: 27452
package main

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

func solve() {
	n := getInt()
	m := n % 2
	as := getIntSlice(n)

	b := make([]int, n)
	l, r := 0, n-1
	for i := n - 1; i >= 0; i-- {
		if (i % 2) != m {
			b[l] = as[i]
			l++
		} else {
			b[r] = as[i]
			r--
		}
	}

	for i := range b {
		fmt.Fprintln(wr, b[i])
	}
}

// -----------------------------------------

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 9472
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(long[]);
    auto N = nm[0];
    auto M = nm[1];
    long al;
    long[long] AM = [0: 0];
    foreach (i, a; readln.split.to!(long[])) {
        al = (al + a) % M;
        ++AM[al];
    }
    long r = AM[0];
    foreach (_, n; AM) r += n * (n-1) / 2;
    writeln(r);
}

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

int main() {
  string s;
  cin >> s;
  int first = -1;
  int last;
  for (int i = 0; i < s.size(); ++i) {
    if (s.at(i) == 'A' && first == -1) {
      first = i;
    }
    if (s.at(i) == 'Z') {
      last = i;
    }
  }
  cout << last - first + 1 << endl;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++)
  {
    cin >> X.at(i);
  }
  int ans = 1000000000;
  sort(X.begin(), X.end());
  for (int i = X.at(0); i <= X.at(N-1); i++)
  {
    int now_ans = 0;
    for (int j = 0; j < N; j++)
    {
      now_ans += (X.at(j) - i) * (X.at(j) - i);
    }
    ans = min(ans, now_ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>

typedef long long ll;
ll n,h,w,x,y,ans=0;

int main()
{
    scanf("%lld%lld%lld",&n,&h,&w);
    while(n--)
    {
        scanf("%lld%lld",&x,&y);
        ans+=x>=h&&y>=w;
    }
    printf("%lld",ans);
    return 0;
}

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

int main() {
  int N;
  double x, S=0;
  string u;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> x >> u;
    if (u=="BTC") {
      S+=x*380000;
    }
    else {
      S+=x;
    }
  }
  cout << S << endl;
}



Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll gcd(ll a, ll b){
  if(b==0) return a;
  else gcd(b,a%b);
}
ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}
using Graph = vector<vector<int> >;
Graph G;

void dfs(int v, vector<bool> &seen, int &res) {
    bool end = true;
    for (int i = 0; i < seen.size(); ++i) if (!seen[i] && i != v) end = false;
    if (end) {
        ++res;
        return;
    }

    seen[v] = true;
    for (auto nv : G[v]) {
        if (seen[nv]) continue;
        dfs(nv, seen, res);
    }
    seen[v] = false;
}
int main(){
  int n,m;
  cin >> n >> m;
  G.assign(n,vector<int>());
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
  vector<bool>seen(n,false);
  int ans=0;
  dfs(0,seen,ans);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
long long n, m, s, a[100005];
int main() {
	int i;
	scanf("%lld", &n);
	for(i=0; i<n; i++) scanf("%lld", &a[i]);
	std::sort(a, a+n);
	for(i=n-1; i; i--) {
		if(a[i]==a[i-1]) {
			if(m==0) m = a[i];
			else {s = m*a[i]; break;}
			i--;
		}
	}
	printf("%lld", s);
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<bits/stdc++.h>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ll long long int
#define F first
#define S second
#define f(i,x,n) for(ll i=x;i<n;i++)
using namespace std;
int main(){
	ll n,sum=0;
	cin>>n;
	ll v[n],dp[n];
	f(i,0,n) cin>>v[i];
	dp[0]=0;
	dp[1]=abs(v[1]-v[0]);
	f(i,2,n){
		dp[i]=min(dp[i-1] +abs(v[i]-v[i-1]),(dp[i-2] +abs(v[i]-v[i-2])));
	}
	cout<<dp[n-1];
return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  int N, q, left, right, mid, ans = 0;
  cin >> N;
  vector<int> S(N, 0);
  for(int i=0; i<N; i++){
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());
  cin >> q;
  vector<int> T(q, 0);
  for(int i=0; i<q; i++){
    cin >> T[i];
  }
  sort(T.begin(), T.end());
  left = 0;
  right = S.size();
  for(int i=0; i<T.size(); i++){
    if(binary_search(S.begin(), S.end(), T[i])){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

ll mod = 1e9 + 7;

ll dp[101][100005];

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
    cout.precision(20); cout << fixed;
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll &e : a) {
        cin >> e;
    }
    for (int i = 0; i <= a[0]; i++) {
        dp[0][i] = i + 1;
    }
    for (int i = a[0] + 1; i <= k; i++) {
        dp[0][i] = dp[0][i - 1];
    }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            dp[i][j] = (dp[i - 1][j] - (j - a[i] - 1 >= 0 ? dp[i - 1][j - a[i] - 1] : 0) + mod) % mod;
            if (j != 0) {
                dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
            }
        }
    }
    if (k == 0) {
        cout << 1;
    } else {
        cout << (dp[n - 1][k] - dp[n - 1][k - 1] + mod) % mod;
    }
}


Measured memory_bytes: 78336
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
typedef long double ld;
int main(){
    cout << fixed  << setprecision(20);
    int N;
    ld n,d,x;
    cin >> N >> d >> x;
    n = N;
    ld s = 0;
    for(int i=1;i<N;i++){
        ld t = i;
        s = s*(t+2)/(t+1) + t/(t+1);
    }
    s /= 2.0;
    cout << (2*d+(2*n-1)*x)*s + (n*d +n*(2*n-1)*x/2.0) << endl;
    return 0;
}

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

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

void solve(int h, int w) {
    int taikaku = h*h + w*w;
    int mi = 114514;
    int px=810, py=810;
    FOR(x,1,151) {
        FOR(y,1,x) {
            int t = x*x + y*y;
            if(t > taikaku or (t==taikaku and y>h)) {
                if(t < mi or (t==mi and y<py)) {
                    mi = t;
                    px = x; py = y;
                }
            }
        }
    }

    cout << py << " " << px << "\n";
}

int main() {
    int h,w;
    while(cin>>h>>w && h) solve(h,w);
    return 0;
}

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

int main(){

  int a;
  int b;
  int c;
  int t;

  cin >> a;
  cin >> b;
  cin >> c;

  if(a > b){

    t = a;
    a = b;
    b = t;

  }

  if(b > c){

    t = b;
    b = c;
    c = t;

  }

  if(a > b){

    t = a;
    a = b;
    b = t;

  }

  cout << a << " " << b << " " << c << endl;

  return 0;

}



Measured memory_bytes: 3080
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>

int main(void) {
  int a, b, c, x;
  std::cin >> a;
  std::cin >> b;
  std::cin >> c;
  std::cin >> x;

  int cnt = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (i * 500 + j * 100 + k * 50 == x) {
          cnt++;
        }
      }
    }
  }
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int n;
bool** edge;


void dfs(int v, bool* flag){

	if(flag[v]){ return; }

	flag[v] = true;

	for(int i = 0; i < n; i++){
		if(edge[v][i]){
			dfs(i, flag);
		}
	}
}


int main(void){

	int m;
	std::cin >> n >> m;

	// 辺が存在するときにtrueとなる
	edge = new bool*[n];
	for(int i = 0; i < n; i++){
		edge[i] = new bool[n];

		for(int j = 0; j < n; j++){
			edge[i][j] = false;
		}
	}

	for(int i = 0; i < m; i++){
		int a, b;
		std::cin >> a >> b;
		edge[a-1][b-1] = true;
		edge[b-1][a-1] = true;
	}

	int bridge = 0;
	
	for(int y = 0; y < n; y++){
		for(int x = y + 1; x < n; x++){

			if(edge[y][x]){

				edge[y][x] = false;
				edge[x][y] = false;
				bool* flag = new bool[n];
				for(int i = 0; i < n; i++){
					flag[i] = false;
				}
				
				dfs(0, flag);
				
				for(int i = 0; i < n; i++){
					if(!flag[i]){
						bridge++;
						break;
					}
				}

				delete[] flag;
				edge[y][x] = true;
				edge[x][y] = true;
			}
		}
	}

	std::cout << bridge << std::endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))
boxes = [0] * (N+1)

for i in range(N, 0, -1):
    # print(i)
    wa = 0
    for j in range(i, N+1, i):
        # print(j)
        wa += boxes[j]
    if wa % 2 != A[i]:
        boxes[i] = 1
    # print("hogeeeeeeeeee")
ans = []
for i in range(len(boxes)):
    if boxes[i] == 1:
        ans.append(i)

print(len(ans))
if len(ans) != 0:
    print(" ".join(map(str, ans)))


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

int main () {
  int n;
  cin >> n;
  vector<string> S(n);
  vector<int> s(n);
  vector<vector<int>> x(n, vector<int>(26));
  for (int i = 0; i < n; i++) {
    cin >> S.at(i);
    s.at(i) = S.at(i).size();
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < s.at(i); j++) {
      int a = S.at(i).at(j) - 'a';
      x.at(i).at(a)++;
    }
  }
  vector<int> y(26);
  for (int i = 0; i < 26; i++) {
    y.at(i) = x.at(0).at(i);
    for (int j = 1; j < n; j++) {
      if (x.at(j).at(i) < y.at(i)) y.at(i) = x.at(j).at(i);
    }
  }
  for (int i = 0; i < 26; i++) {
    if (y.at(i) != 0) {
      for (int j = 0; j < y.at(i); j++) {
        cout << char(i+'a');
      }
    }
  }
}

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

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 200100;
const int offset = (1 << 18);

struct tournament {
  ll p[offset * 2], prop[offset * 2];

  void send_prop(int cvor) {
    FOR(i, cvor * 2, cvor * 2 + 2) {
      prop[i] += prop[cvor];
      p[i] += prop[cvor];
    }
    prop[cvor] = 0;
  }

  void update(int cvor, int l, int r, int a, int b, ll x) {
    if (l > b || r < a) return;
    if (l >= a && r <= b) {
      prop[cvor] += x;
      p[cvor] += x;
      return;
    }

    send_prop(cvor);

    int mid = (l + r) / 2;

    update(cvor * 2, l, mid, a, b, x);
    update(cvor * 2 + 1, mid + 1, r, a, b, x);

    p[cvor] = max(p[cvor * 2], p[cvor * 2 + 1]);
  }

  ll get(int cvor, int l, int r, int a, int b) {
    if (l > b || r < a) return -(1LL << 50);
    if (l >= a && r <= b) return p[cvor];
    
    send_prop(cvor);

    int mid = (l + r) / 2;

    ll x = get(cvor * 2, l, mid, a, b);
    ll y = get(cvor * 2 + 1, mid + 1, r, a, b);
    return max(x, y);
  }

  void print() {
    FOR(i, 1, offset * 2) {
      TRACE(i _ p[i] _ prop[i]);
    }
  }
};

tournament T;

int n, m;

int L[MAXN], R[MAXN];
ll C[MAXN];

vector <int> v[MAXN];
ll dp[MAXN];

int main() {
  scanf("%d %d",&n,&m);
  REP(i, m) {
    scanf("%d %d %lld",&L[i],&R[i],&C[i]);
    T.update(1, 0, offset - 1, L[i], n + 1, -C[i]);
    T.update(1, 0, offset - 1, R[i] + 1, n + 1, C[i]);
    v[R[i] + 1].push_back(i);
  }

  //T.print();
  FOR(i, 1, n + 2) {
    for (auto x : v[i]) {
      T.update(1, 0, offset - 1, L[x], n + 1, C[x]);
      T.update(1, 0, offset - 1, R[x] + 1, n + 1, -C[x]);
    }
    //TRACE(i _ T.get(1, 0, offset - 1, 0, i - 1) _ T.get(1, 0, offset - 1, i, i));
    dp[i] = T.get(1, 0, offset - 1, 0, i - 1) - T.get(1, 0, offset - 1, i, i);
    T.update(1, 0, offset - 1, i, i, dp[i]);
  }

  cout << dp[n + 1] << endl;
  return 0;
}


Measured memory_bytes: 23552
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

void start() {
	#ifndef ONLINE_JUDGE 
		freopen("in", "r", stdin); 
		freopen("out", "w", stdout); 
	#endif
}

int n;
int arr[15][3],store[17];
int ans[1ll<<15][15];
int ans1[1ll<<15][15];

int power(int x,int y,int p)
{ 
    int res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if((y & 1)==1) 
            res = (res * x) % p; 
        y = y >> 1;  
        x = (x * x) % p;  
    } 
    return res; 
} 

int32_t main() {
    IOS;
    start();

    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }

    for(int i = 0; i < 1ll << n; i++) {
        for(int j = 0; j < n; j++) {
            ans[i][j] = abs(arr[j][0]) * arr[j][2];
            ans1[i][j] = abs(arr[j][1]) * arr[j][2];
            for(int k = 0; k < n; k++) {
                if(i & (1ll << k)) {
                    ans[i][j] = min(ans[i][j], 
                        abs(arr[k][0] - arr[j][0]) * arr[j][2]);
                    ans1[i][j] = min(ans1[i][j], 
                        abs(arr[k][1] - arr[j][1]) * arr[j][2]);
                }
            }
        }
    }

    for(int i = 0; i < 17; i++)
        store[i] = 1e18;

    for(int i = 0; i < power(3, n, 1e18); i++) {\
        int bit1 = 0, bit2 = 0;
        int bit = 0;
        int ctr = 0;
        int temp = i;
        while(bit != n) {
            int dig = temp % 3;
            if(dig == 1) {
                bit1 |= (1ll << bit);
                ctr++;
            }
            if(dig == 2) {
                bit2 |= (1ll << bit);
                ctr++;
            }
            temp /= 3;
            bit++;
        }
        int sum = 0;
        for(int j = 0 ; j < n; j++) {
            sum += min(ans[bit1][j], ans1[bit2][j]);
        }
        store[ctr] = min(store[ctr], sum);
    }

    for(int i = 0; i<=n; i++) {
        cout << store[i] << endl;
    }
}   







Measured memory_bytes: 11340
#include <stdio.h>

int main() {
	int a,b,c,i,x,s;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++)
	{
		x=c%i;
		if(x==0) {s++;continue;}
	}
	
	printf("%d\n",s);
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

int N, A;
int x[51];
ll dp[51][10000];
int shift = 5000;

ll dpf(int n, int sum){
  if(dp[n][sum+shift]>=0){
    return dp[n][sum+shift];
  }else{
    if(n==1){
      dp[n][sum+shift]=0;
      if(sum==x[n]){
        dp[n][sum+shift] += 1;
      }
      if(sum == 0){
        dp[n][sum+shift] += 1;
      }
      return dp[n][sum+shift];
    }else{
      dp[n][sum + shift] = dpf(n-1, sum) + dpf(n-1, sum - x[n]);
      return dp[n][sum + shift];
    }
  }
}

void dp_reset(){
  rep(i, 51){
    rep(j, 10000){
      dp[i][j] = -100;
    }
  }
  return;
}
/******************************************
** A main function is start from here  ****
*******************************************/
int main(){
  cin >> N >> A;
  for(int i=1;i<=N;i++){
    cin >> x[i];
    x[i] -= A;
  }
  
  dp_reset();
  cout << dpf(N, 0) - 1;
  
  
  return 0;
}


Measured memory_bytes: 4224
#include<cstdio>
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a>0)return printf("Positive"),0;
	if(a==0)return printf("Zero"),0;
	if(b>0)return printf("Zero"),0;
	if(b==0)return printf("Zero"),0;
	if((b-a+1)&1)return printf("Negative"),0;
	return printf("Positive"),0;
}

Measured memory_bytes: 1732
#[allow(unused_imports)]
use {
    itertools::Itertools,
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::io::Write,
    std::ops::*,
};

#[allow(unused_macros)]
macro_rules! dbg { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; }

#[fastout]
fn main() {
    input! {
        n: usize,
        q: usize,
        query: [(usize, Usize1); q]
    }
    let mut a = vec![n - 1; n];
    let mut b = vec![n - 1; n];
    let mut ans = (n - 2) * (n - 2);
    let mut w = n - 1;
    let mut h = n - 1;
    for (t, x) in query {
        if t == 1 {
            if x < w {
                for i in x..w {
                    a[i] = h;
                }
                w = x;
            }
            ans -= a[x] - 1;
        } else {
            if x < h {
                for i in x..h {
                    b[i] = w;
                }
                h = x;
            }
            ans -= b[x] - 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 9884
#include<stdio.h>
struct runnner
{
	int bangou;
	float taimu;
};

float swap(float a)
{
	int b;
	a=a*100+0.5;
	b=(int)a;
	a=(float)b;
	return a;
}

int main()
{
	struct runnner r[24],ll;
	int i,j;
	for(i=0;i<24;i++)
	{
		scanf("%d",&r[i].bangou);
		scanf("%f",&r[i].taimu);
	}
	for(i=0;i<7;i++)
	{
		for(j=i+1;j<8;j++)
		{
			if(r[i].taimu>r[j].taimu)
			{
				ll=r[i];
				r[i]=r[j];
				r[j]=ll;
			}
		}
	}
	for(i=8;i<15;i++)
	{
		for(j=i+1;j<16;j++)
		{
			if(r[i].taimu>r[j].taimu)
			{
				ll=r[i];
				r[i]=r[j];
				r[j]=ll;
			}
		}
	}
	for(i=16;i<23;i++)
	{
		for(j=i+1;j<24;j++)
		{
			if(r[i].taimu>r[j].taimu)
			{
				ll=r[i];
				r[i]=r[j];
				r[j]=ll;
			}
		}
	}
	r[4]=r[10];
	r[5]=r[11];
	r[6]=r[18];
	r[7]=r[19];
	for(i=2;i<4;i++)
	{
		for(j=i+1;j<8;j++)
		{
			if(r[i].taimu>r[j].taimu)
			{
				ll=r[i];
				r[i]=r[j];
				r[j]=ll;
			}
		}
	}
	printf("%d %4.2f\n",r[0].bangou,r[0].taimu);
	printf("%d %4.2f\n",r[1].bangou,r[1].taimu);
	printf("%d %4.2f\n",r[8].bangou,r[8].taimu);
	printf("%d %4.2f\n",r[9].bangou,r[9].taimu);
	printf("%d %4.2f\n",r[16].bangou,r[16].taimu);
	printf("%d %4.2f\n",r[17].bangou,r[17].taimu);
	printf("%d %4.2f\n",r[2].bangou,r[2].taimu);
	printf("%d %4.2f\n",r[3].bangou,r[3].taimu);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::cin >> n;
	std::vector<uint32> c, s, f;
	uint32 t1, t2, t3;
	rep(i, 0, n - 1) {
		std::cin >> t1 >> t2 >> t3;
		c.push_back(t1);
		s.push_back(t2);
		f.push_back(t3);
	}
	rep(i, 0, n) {
		uint32 t = 0;
		rep(j, i, n - 1) {
			if (t < s[j]) {
				t = s[j];
			}
			if (t%f[j]) {
				t += (f[j] - t%f[j]);
			}
			t += c[j];
		}
		std::cout << t << "\n";
	}
	return 0;
}

Measured memory_bytes: 384
from collections import deque

MOD = 1000000007
n, k = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n-1)]
edges = [set() for _ in range(n)]
visited = [False for _ in range(n)]
for a, b in AB:
    edges[a-1].add(b-1)
    edges[b-1].add(a-1)

upper = max(n, k)
fact = [1] * (upper+1)
fact_inv = [1] * (upper+1)
for i in range(1, upper+1):
    fact[i] = fact[i-1] * i % MOD
fact_inv[upper] = pow(fact[upper], MOD-2, MOD)
for i in range(upper-1, 0, -1):
    fact_inv[i] = fact_inv[i+1] * (i+1) % MOD
def perm(n, r):
    if n < r or r < 0:
        return 0
    return fact[n] * fact_inv[n-r] % MOD

q = deque([0])
visited[0] = True
first = True
ans = k
while q:
    v = q.popleft()
    visited[v] = True
    children = list(filter(lambda x: not visited[x], edges[v]))
    if first:
        ans *= perm(k-1, len(children))
        ans %= MOD
        first = False
    else:
        ans *= perm(k-2, len(children))
        ans %= MOD
    q.extend(children)
print(ans)


Measured memory_bytes: 71688
# frozen_string_literal: true

n = gets.to_i
h = gets.split.map(&:to_i)

max = 0
count = 0

1.upto(n - 1) do |i|
  if h[i - 1] >= h[i]
    count += 1
    max = count if max < count
  else
    count = 0
  end
end

puts max


Measured memory_bytes: 8580
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

module Gcd =

    let inline gcd (x: ^a) (y: ^a): ^a =
        let zero = LanguagePrimitives.GenericZero

        let rec loop x y =
            if y = zero then x else loop y (x % y)
        loop x y

    let inline lcm (x: ^a) (y: ^a): ^a =
        let g = gcd x y
        x / g * y

let f x =
    let mutable cnt = 0L
    let mutable x = x
    while x % 2L = 0L do
        x <- x / 2L
        cnt <- cnt + 1L
    cnt

let main() =
    let [| N; M |] = reada int64
    let A = reada int64 |> Array.map (fun a -> a / 2L)
    let ts = Array.map f A
    let mutable ok = true
    for t in ts do
        if t <> ts.[0] then ok <- false
    match ok with
    | false -> puts 0
    | true ->
        let lcm = Array.fold (fun acc a -> Gcd.lcm acc a) A.[0] A
        let cnt = M / lcm
        let cnt = (cnt + 2L - 1L) / 2L // lcmの奇数倍のみを数え上げる
        puts cnt

    ()

main()
writer.Close()


Measured memory_bytes: 31324
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    N = parseInt(readline())
    ans = 0
    for i in 1:N
        h = (N - 1) ÷ i
        ans += h
    end
    println(ans) 
end


main()

Measured memory_bytes: 157936
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/
 
ll n,a,b,H;
ll l,r,mid;
vector<ll>h;
 
bool check(int cnt){
  ll index=upper_bound(all(h),cnt*b)-h.begin();
  ll con=cnt*b;
  for(ll i=index;i<n;i++){
    cnt-=(h[i]-con)/(a-b);
    if((h[i]-con)%(a-b)!=0)cnt--;
    if(cnt<0)return false;
  }
  return true;
}
 
int main(){
  scanf("%d%d%d",&n,&a,&b);
  rep(i,n){scanf("%d",&H);h.pb(H);}
  sort(all(h));
  l=0;r=1000000001;mid=(l+r)/2;
  while(l<r){
    if(check(mid))r=mid;
    else l=mid+1;
    mid=(l+r)/2;
  }
  cout<<mid<<endl;
  return 0;
}

Measured memory_bytes: 1400
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    ll ans = 0;
    int tmp;
    int n;
	cin >> n;
	vector<pair<ll, int>> a;
	REP(i, n){
		cin >> tmp;
		a.push_back(make_pair((ll)tmp, i));
	}
	sort(a.begin(), a.end());
	ll dp[n+1][n+1] = {};
	dp[0][0]= 0;
	REP1(i, n){
		for(int j = 0; j <= i; j++){ // 大きい数字i個中j個が左に寄った
			ll ext = a[n-i].first;
			int whe = a[n-i].second;
			if(j > 0 && j < i)dp[i][j] = max(dp[i-1][j]   + ext * (ll)abs(whe - (n-1-(i-1-j)) ),
									dp[i-1][j-1] + ext * (ll)abs(whe - (j-1)   ) ); 
			else if(j==0) dp[i][j] = dp[i-1][j] + ext * (ll)abs(whe - (n-1-(i-1-j)) );
			else dp[i][j] = dp[i-1][j-1] + ext * (ll)abs(whe - (j-1) );
			//cout << dp[i][j] << endl;
		}
	}
	REP(i, n+1) ans = max(ans, dp[n][i]);
    cout << ans << endl;
}

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

int main()
{ 
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B){
    cout<<C; 
  }
  else if (C==B){
    cout<<A;
  }
  else {
    cout<<B;
  }  
  return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int n,t,a[200000],result=0,i;

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

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

  for(i = 0; i < n-1; i++){

    if(a[i+1]-a[i] < t) result += a[i+1]-a[i];
    else result	+= t;

  }

  result += t;
  printf("%d\n",result);

  return 0;

}

















Measured memory_bytes: 896
import math
n = int(input())
dig = math.log10(n)
if dig<1:
    print(n)
elif 1 <= dig and dig < 2:
    print(9)
elif 2 <= dig and dig < 3:
    print(9+n-99)
elif 3 <= dig and dig < 4:
    print(9+999-99)
elif 4 <= dig and dig < 5:
    print(9+999-99+n-9999)
else:
    print(9+999-99+99999-9999)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef long double ldbl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
// constant
const double PI  = acos(-1.0);
const int    MOD = (int)(1e9 + 7);
// DO NOT set INFTY_XXXs constants. They may bring some BUG! Use MAX_XXXs in climit instead.
 
// clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
// debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl


template<typename T>
inline vector<T> cin_vector(const size_t n) {
     vector<T> vec;
    vec.reserve(n);
    REP(i, n) {
        T element; cin >> element;
        vec.push_back(element);
    }
    return vec;
}

template<typename T>
inline vector< vector<T> > cin_matrix(const size_t m, const size_t n) {
    vector< vector<T> > matrix;
    matrix.reserve(m);
    REP(i, m) {
        vector<T> vec = cin_vector<T>(n);
        matrix.push_back(vec);
    }
    return matrix;
}

template<typename T>
inline void cout_vector(const vector<T>& vec) {
    REP(i, SZ(vec)-1) {
       cout << vec[i] << ' ';
    }
    cout << vec[SZ(vec)-1] << endl;
}

template<typename T>
inline void cout_matrix(vector< vector<T> > matrix) {
    for(const vector<T>& vec : matrix) {
         cout_vector<T>(vec);
    }
}


int main() {
    ll n, m; cin >> n >> m;
    unordered_map<ll, ll> mod_map;
    ll mod_sum = 0;
    mod_map[0]++;
    REP(i, n) {
        ll e; cin >> e;
        mod_sum = (mod_sum + e) % m;
        mod_map[mod_sum]++;
    }
    ll ans = 0;
    for (const auto& p : mod_map) {
        ll c = p.second;
        ans += (c-1) * c / 2;
    }

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


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  stack<double> st;
  for(int i=0;i<n;++i) {
    st.push(v[i]);
  }
  while(st.size() > 1) {
    double a = st.top(); st.pop();
    double b = st.top(); st.pop();
    st.push((a + b) / 2);
  }
  cout << st.top() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
bool check(string& s, vector<pair<int,int>>& q)
{
	for(int i=0; i<q.size(); i++)
	{
		if(s[q[i].first-1]-'0' != q[i].second)
			return false;
	}
	return true;
}
int main() {
	ll n,m;
	cin>>n>>m;
	vector<pair<int,int> > q(m);
	for(int i = 0; i<m; i++)
	{
		cin>>q[i].first >> q[i].second;
	}
	for(int i=0; i<=999; i++)
	{
		string s = to_string(i);
		if(check(s,q) && s.size() == n)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int h,w;
  string c,d;
  cin>>h>>w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>c;
      if(c=="snuke"){
	d=64+j;
	cout<<d<<i<<"\n";
      }
    }
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
int n;
char res[10];
void dfs(int id,int c,int mx,bool flag){
    if(id==n){
        rep(i,n){
            cout << res[i];
        }
        cout << "\n";
        return;
    }
    if(!flag){
        for(int i=0;i<=mx;i++){
            res[id] = 'a'+i;
            flag = 1;
            dfs(id+1,i,mx,flag); 
        }
    }else{
        for(int i=0;i<mx+2;i++){
            res[id] = 'a'+i;
            dfs(id+1,i,max(mx,i),flag); 
        }
    }
}

int main(){
    cin >> n;
    dfs(0,0,0,0);
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int A, B, T;
    cin >> A >> B >> T;
    long long res = 0;
    int q = A;
    while (q <= T) {
        res += B;
        q += A;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

// 10min
int main(void){
  int n;
  int k;
  char s[51];

  scanf("%d%d%s", &n, &k, s);

  if(s[k-1] == 'A'){
    s[k-1] = 'a';
  }else if(s[k-1] == 'B'){
    s[k-1] = 'b';
  }else if(s[k-1] == 'C'){
    s[k-1] = 'c';
  }

  
  printf("%s\n", s);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<sstream>
#include<map>
#include<queue>
using namespace std;
#define int long long
int H, W, V, T, X, Y, P, Q;
int R;
int cnt(int x, int y) {
	if (R < abs(x))return 0;
	double t = sqrt(R*R - x*x);
	int b1 = ((t - y) / (2 * H)) + 3;
	int b2 = ((-t - y) / (2 * H)) - 3;
	int c = 0;
	while (true) {
		if (x*x + (y + 2 * b1 * H)*(y + 2 * b1 * H) <= R*R) {
			break;
		}
		b1--;
		c++;
		if (c == 10)break;
	}
	if (c == 10)return 0;
	c = 0;
	while (true) {
		if (x*x + (y + 2 * b2 * H)*(y + 2 * b2 * H) <= R*R) {
			break;
		}
		b2++;
		c++;
		if (c == 10)break;
	}
	if (c == 10)return 0;
	return b1 - b2 + 1;
}
int solve(int x, int y) {
	x = abs(x) % (2 * W);
	y = abs(y) % (2 * H);
	int res = cnt(x, y);
	//cerr << x << " " << y << " " << res << endl;
	int t;
	int a = 1;
	while (true) {
		t = cnt(x + 2 * a*W, y);
		if (t == 0)break;
		res += t;
		a++;
	}
	a = -1;
	while (true) {
		t = cnt(x + 2 * a*W, y);
		if (t == 0)break;
		res += t;
		a--;
	}
	return res;
}
signed main() {

	cin >> W >> H >> V >> T >> P >> Q >> X >> Y;
	R = V*T;
	int res = 0;
	res += solve(X - P, Y - Q);
	res += solve(2 * W - X - P, Y - Q);
	res += solve(X - P, 2 * H - Y - Q);
	res += solve(2 * W - X - P, 2 * H - Y - Q);
	cout << res << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
 
//#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

string s;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> s;
	sort(all(s));

	if (s[0] != s.back()) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using static AtCoderer.Exter;
using static System.Math;
using System.Linq;

namespace AtCoderer
{

    public class App
    {
        public static void Solve()
        {
            int[] r = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            int a = r[0];
            int b = r[1];
            int c = r[2];
            Console.WriteLine(a + b + c - Max(a,b,c));
        }
        public static void Main(string[] args)
        {
            Solve();
            Console.ReadKey();
        }
    }
    public static class Exter
    {
        public static void rep(int loop, Action<int> act)
        {
            for (int i = 0; i < loop; i++)
                act(i);
        }
        public static int Max(params int[] p) => p.Max();
        public static long Max(params long[] p) => p.Max();
        public static int Min(params int[] p) => p.Min();
        public static long Min(params long[] p) => p.Min();
        public static int Gcd(int a, int b) => a > b ? GcdRecursive(a, b) : GcdRecursive(b, a);
        private static int GcdRecursive(int a, int b) => b == 0 ? a : GcdRecursive(b, a % b);
        public static void EnumArr<t>(this IEnumerable<t> v)
        {
            Console.WriteLine(string.Join(",", v));
        }
        public static string ToString(this IEnumerable<char> v)
        {
            return string.Join(",", v);
        }
        public static int[] readarr
        {
            get
            {
                return Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            }
        }
        public class UnionFind
        {
            private int[] Parent;
            private int GetRoot(int v)
            {
                if (Parent[v] < 0)
                    return v;
                else
                    return Parent[v] = GetRoot(Parent[v]);
            }
            public UnionFind(int size)
            {
                Parent = new int[size];
                for (int i = 0; i < size; i++)
                    Parent[i] = -1;
            }
            public bool AreGrouped(int a, int b)
            {
                return GetRoot(a) == GetRoot(b);
            }
            public void Connect(int a, int b)
            {
                a = GetRoot(a);
                b = GetRoot(b);
                if (a == b) return;
                if(Parent[b]<Parent[a])
                {
                    Parent[b] += Parent[a];
                    Parent[a] = b;
                }
                else
                {
                    Parent[a] += Parent[b];
                    Parent[b] = a;
                }
            }
            public int GetGroupSize(int a)
            {
                return -Parent[GetRoot(a)];
            }
        }
    }
}


Measured memory_bytes: 13396
package main

import (
  "fmt"
)

func main () {
  var (
  	n, k, x, y int
    ans int
  )
  
  fmt.Scan(&n)
  fmt.Scan(&k)
  fmt.Scan(&x)
  fmt.Scan(&y)
  
  
  for i := 0; i < n; i++ {
    if i >= k {
    	ans += y
    }else{
    	ans += x
    }
  }
  
  fmt.Println(ans)


}

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

int main() {
  int a; cin>>a;
  string s="No";
  for(int i=1;i<10; i++){
    if(a%i==0 && a/i<10){
      s="Yes";
    //cout<<i<<" "<<a/i<<endl;
    break;}
  }
  cout<<s;
}

Measured memory_bytes: 256