akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll H, W; cin >> H >> W;
    if(H % 3 == 0 || W % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = min(H, W);
    for (int i = 1; i < H; i++){
        ll s1 = i*W;
        ll s2, s3, sa;
        if(W % 2 == 0){
            s2 = (H-i) * (W/2);
            sa = abs(s1-s2);
        } else {
            s2 = (H-i) * (W/2 + 1);
            s3 = (H-i) * (W/2);
            sa = max(abs(s1-s2), abs(s1-s3));
            sa = max(sa, abs(s2-s3));
        }
        ans = min(ans, sa);
    }

    for (int i = 1; i < W; i++){
        ll s1 = i*H;
        ll s2, s3, sa;
        if(H % 2 == 0){
            s2 = (W-i) * (H/2);
            sa = abs(s1-s2);
        } else {
            s2 = (W-i) * (H/2 + 1);
            s3 = (W-i) * (H/2);
            sa = max(abs(s1-s2), abs(s1-s3));
            sa = max(sa, abs(s2-s3));
        }
        ans = min(ans, sa);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int D, X;
    cin >> D >> X;
    int A;
    int ans = X;
    rep(i, N) {
        cin >> A;
        for(int i = 1; i <= D; i += A) ans++;
    }
    cout << ans << endl;


    return 0;
}


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

int H,W,sum;
char BW[50][50];

int judgeW(int h,int w)
{
  int a=0,b=0,c=0,d=0;
  if(h<0 || h>=H || w<0 || w>=W || BW[h][w]=='B' ||BW[h][w]=='0')return 0;
  if(BW[h][w]=='W')return 1;
  if(BW[h][w]=='.'){
    BW[h][w]='0';
    sum++;
  }
  a=judgeW(h+1,w);
  b=judgeW(h,w+1);
  c=judgeW(h-1,w);
  d=judgeW(h,w-1);
  return (a+b+c+d);
}
int judgeB(int h,int w)
{
  int a=0,b=0,c=0,d=0;
  if(h<0 || h>=H || w<0 || w>=W || BW[h][w]=='W' ||BW[h][w]=='1')return 0;
  if(BW[h][w]=='B')return 1;
  if(BW[h][w]=='0')BW[h][w]='1';
  a=judgeB(h+1,w);
  b=judgeB(h,w+1);
  c=judgeB(h-1,w);
  d=judgeB(h,w-1);
  return (a+b+c+d);
}

int main()
{
  int a,b,sumb,sumw;
  while(1){
    cin>>W>>H;
    if(H==0&&W==0)break;
    sumb=0;sumw=0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin>>BW[i][j];
      }
    }
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
     	if(BW[i][j]=='.'){
	  sum=0;
	  a=judgeW(i,j);
          b=judgeB(i,j);
	  if((a!=0 && b!=0)||(a==0&&b==0))continue;
          else if(a>0)sumw+=sum;
	  else sumb+=sum;
	  }
      }
    }
    cout<<sumb<<" "<<sumw<<endl;
  }
  return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
typedef pair<long,long> T;
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int N,M;
vector<int> g[size];
vector<T> dp[size];// dp[v][i] v to end
T e1 = {1, 1}, e2 = {0, 1};// left identify, right identify
map<int,T> L[size],R[size];
T ans[size];
T func1(T x, T y){// F x f
	T p;
	p.first = x.first * (y.first + y.second % M) % M;
	p.second = x.second * y.second % M;
    return p;
}T func2(T x, T y){// F x F
	T p;
	p.first = x.first * y.first % M;
	p.second = x.second * y.second % M;
    return p;
}
T dfs1(int p, int v){
    T res = e1;
	for(int u:g[v]){
        if(u == p) continue;
		dp[v].push_back(dfs1(v, u));
        res = func1(res, dp[v].back());
	}return res;
}
void dfs2(int p, int v){
	ans[v] = func1(R[v][0], dp[v].back());
    T t;
    int j = 0;
	for(int u:g[v]){
		if(u == p) continue;
        t = func1(func2(L[v][j], R[v][j+1]), dp[v].back());
        dp[u].push_back(t);
		dfs2(v, u);
        j++;
	}return;
}
int main(){
	cin>>N>>M;
	int a,b;
	rep(i,0,N-1){
		cin>>a>>b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs1(-1, 0);
	rep(i,0,N){
		L[i][0] = e1; R[i][dp[i].size()] = e1;
		rep(j,0,dp[i].size()) L[i][j+1] = func1(L[i][j], dp[i][j]);
		for(int j = dp[i].size(); j > 0; j--) R[i][j-1] = func1(R[i][j], dp[i][j-1]);
	}
	dp[0].push_back(e2);
	dfs2(-1, 0);
	rep(i,0,N){
		cout<<ans[i].first<<endl;
	}
}

Measured memory_bytes: 59520
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

char A[1010][1010];
int d[1010][1010];

int main() {
	int n, m; scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++) scanf("%s", A[i]+1);
	vector <pii> q;
	int ans = 0;
	memset(d, -1, sizeof d);
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(A[i][j] == '#') q.pb(pii(i, j)), d[i][j] = 0;
	int xx[4] = {1, 0, -1, 0};
	int yy[4] = {0, 1, 0, -1};
	rep(i, szz(q)) {
		rep(dir, 4) {
			int nx = q[i].Fi + xx[dir];
			int ny = q[i].Se + yy[dir];
			if(1 <= nx && nx <= n && 1 <= ny && ny <= m && d[nx][ny] == -1) {
				ans = d[nx][ny] = d[q[i].Fi][q[i].Se] + 1;
				q.pb(pii(nx, ny));
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 15212
N = int(input())
A= list(map(int,input().split()))
Q = int(input())
heavy = [0] * (10 ** 5 + 1)
for i in A:
  heavy[i] += 1
s = sum(A)
for i in range(Q):
  be,af = map(int,input().split())
  s -= be * heavy[be]
  s += af * heavy[be]
  heavy[af] += heavy[be]
  heavy[be] = 0
  print(s)

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

int H, W;
char s[21][21];

const int INF = 1e9 + 7;

pair<vector<vector<int>>, bool> warshallFloyd(const int V, vector<vector<int>> G) {
    for (int v = 0; v < V; v++) {
        G[v][v] = 0;
    }
    for(int k = 0; k < V; k++) {
        for(int i = 0; i < V; i++) {
            for(int j = 0; j < V; j++) {
                if(G[i][k] >= INF || G[k][j] >= INF)
                    continue;
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
    bool negativeLoop = false;
    for (int v = 0; v < V; v++) {
        if (G[v][v] < 0) {
            negativeLoop = true; 
            break;
        }
    }
    return {G, negativeLoop};
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> H >> W;
    for (int ci = 0; ci < H; ci++) {
        for (int ri = 0; ri < W; ri++) {
            cin >> s[ci][ri];
        }
    }
    vector<vector<int>> G(H * W, vector<int>(H * W, INF));
    for (int i = 0; i < H; i ++) {
        for (int j = 0; j < W; j++) {
            if (s[i][j] != '.') {
                continue;
            }
            if (j + 1 < W && s[i][j + 1] == '.') {
                G[i * W + j][i * W + j + 1] = 1;
                G[i * W + j + 1][i * W + j] = 1;
            }
            if (i + 1 < H && s[i + 1][j] == '.') {
                G[i * W + j][(i + 1) * W + j] = 1;
                G[(i + 1) * W + j][i * W + j] = 1;
            }
        }
    }
    tie(G, ignore) = warshallFloyd(H * W, G);
    int max = 0;
    for (auto& u: G) {
        for(auto v: u) {
            if (v < INF && v > max) {
                max = v;
            }
        }
    }
    cout << max << endl;

    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N, K; cin >> N >> K;
    string S; cin >> S;
    S[K-1] += 0x20;
    cout << S << endl;
}   



Measured memory_bytes: 888
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    cnt=0
    now=1
    
    for i in range(N):
        if A[i]==now:
            now+=1
        else:
            cnt+=1
            
    if cnt==N:
        cnt=-1
    print(cnt)
        

main()


Measured memory_bytes: 100700
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			int N = sc.nextInt();
			int[] D = new int[9];
			for(int i = 0; i < N; i++){
				int now = sc.nextInt();
				if(now>=3200){
					D[8]++;
				}else{
					D[now/400]++;
				}
			}
			int ansmin = 0, ansmax = 0;
			for(int i = 0; i < 8; i++){
				if(D[i]!=0){
					ansmin++;
					ansmax++;
				}
			}
			if(ansmin == 0){
				ansmin++;
			}
			ansmax += D[8];
			System.out.println(ansmin + " " + ansmax);
		}
	}
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int K = sc.nextInt();
            int A = sc.nextInt();
            int B = sc.nextInt();

            boolean possible = false;

            if(A<=K*(B/K)&&K*(B/K)<=B) possible = true;

            System.out.println(possible?"OK":"NG");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 32756
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
ll a, b, n;
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	qread(a);
	qread(b);
	qread(n);
	if(n < b){
		cout << (a * n) / b;
	} else {
		cout << (a * (b - 1)) / b;
	}
	puts("");
	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define MOD 1000000007
#define ll long long

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

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

int main(int argc, char **argv){
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if(a>=b) printf("delicious\n");
    else if(b-a>x) printf("dangerous\n");
    else printf("safe\n");

    return 0;
}

void swap(int *a, int *b){
    int tmp=*a;
    *a = *b;
    *b = tmp;
}


Measured memory_bytes: 128
#include<stdio.h>
#define M 10000

int main(void){
  int i,j,k;
  int data[M][3],data_num;
  int count_flag;
  int inq;
  char hoge;

  for(i=0;;i++){
    scanf("%d%c%d",
        &data[i][0],&hoge,&data[i][1]);
    if(data[i][0]==0 && data[i][1]==0)
      break;
  }
  data_num=i;

  k=1;
  for(i=30;i>=0;i--){
    count_flag=0;
    for(j=0;j<data_num;j++)
      if(data[j][1]==i){
        data[j][2]=k;
        count_flag=1;
      }
    if(count_flag==1)
      k++;
  }

  for(;scanf("%d",&inq)==1;)
    printf("%d\n",data[inq-1][2]);
  
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<string.h>
using namespace std;
char s[101];
int l;
void cf(){
	l=strlen(s);
	for(int i=0;i<l-1;i++){
	if(s[i]=='C'){
	for(int j=i;j<l;j++){
	if(s[j]=='F'){
	printf("Yes\n");
	return;
	}
	}
	}
	}
	printf("No\n");
	return;
}	
int main(void){


scanf("%s",s);
cf();
return 0;
}

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

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 2019;

void Main() {
  int l, r;
  cin >> l >> r;
  if (r - l >= mod) {
    l = 0;
    r = mod - 1;
  } else {
    r -= (l/mod) * mod;
    l = l % mod;
  }
  int ans = mod;
  REP(i, l, r) REP(j, i+1, r+1) ans = min(ans, (i*j) % mod);
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(double x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> x(n);
	for (int i = 0; i < n; ++i) { cin >> x[i]; }
	sort(x.begin(), x.end());
	ll sum = 0;
	for (int i = 0; i < n - 1; ++i) { sum += x[i]; }
	if (sum > x[n - 1]) {
		dump("Yes");
	} else
		dump("No");
}

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

#define f(i, q) for(int i = 0; i < q; i++)  

typedef long long ll;

int main() {
    string k;
    int sum = 0;

    cin >> k;

    for(int i = 0; i < k.size(); i++) {
        if(k.at(i) == 'o') sum++;
    }

    sum += 15 - k.size();

    if(sum >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val c = cin.nextInt()
    val k = cin.nextInt()

    var t: MutableList<Long> = mutableListOf()

    for (i in 0..n-1) {
        t.add(cin.nextLong())
    }

    val t_sorted = t.sorted()

    var fastest = t_sorted[0]
    var ans = 1
    var passengers = 1
    for (i in 1..n-1) {
        if (t_sorted[i] > fastest + k) {
            ans += 1
            fastest = t_sorted[i]
            passengers = 1
        } else if (passengers == c) {
            ans += 1
            fastest = t_sorted[i]
            passengers = 1
        } else {
            passengers += 1
        }
    }

    println(ans)
}

Measured memory_bytes: 60792
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
count = 0
for i in range(n):
    a = list(map(int,input().split()))
    num = c
    for j in range(m):
        num += a[j]*b[j]
    if num > 0:
        count += 1 
print(count)

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

using namespace std;
const int MXN = 55;
const long long MOD = 1e9 + 7;

long long k , dp[MXN][MXN] , ans[MXN][MXN] , l[MXN][MXN] , temp[MXN][MXN];
int n;

void mul(){
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            temp[i][j] = 0;
            for(int k = 0 ; k < n ; k++){
                temp[i][j] += dp[i][k] * dp[k][j];
                temp[i][j] %= MOD;
            }
        }
    }
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            dp[i][j] = temp[i][j];
        }
    }
}

void mul2(){
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            temp[i][j] = 0;
            for(int k = 0 ; k < n ; k++){
                temp[i][j] += ans[i][k] * dp[k][j];
                temp[i][j] %= MOD;
            }
        }
    }
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            ans[i][j] = temp[i][j];
        }
    }
}

int main(){
    scanf("%d %lld" ,&n ,&k);
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            scanf("%lld" ,&dp[i][j]);
            l[i][j] = dp[i][j];
            ans[i][j] = dp[i][j];
        }
    }
    long long a = 0;
    k--;
    while(k > 0){
        if((k & 1)){
            mul2();
        }
        k >>= 1;
        mul();
    }
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            a += ans[i][j];
            if(a >= MOD){
                a -= MOD;
            }
        }
    }
    printf("%lld" ,a);
}

Measured memory_bytes: 384
program main
  implicit none
  character(100) :: s, t
  read(*, *) s, t
  if (sorted(trim(s), .false.) <sorted(trim(t), .true.)) then
    write(*, "(a)") "Yes"
  else
    write(*, "(a)") "No"
  end if
  contains
  function sorted(s, reverse)
    implicit none
    character(*), intent(in) :: s
    logical, intent(in) :: reverse
    character(len(s)) :: sorted
    character(1) :: tmp
    integer :: i, j
    sorted = s
    do i = 2, len(s)
      do j = 1, i - 1
        if (sorted(i:i) < sorted(j:j) .neqv. reverse) then
          tmp = sorted(i:i)
          sorted(i:i) = sorted(j:j)
          sorted(j:j) = tmp
        end if
      end do
    end do
  end function sorted
end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false); 

    int n,m,r;
    cin >> n >> m >> r;
    vector<int> town(r);
    rep(i,r) {
        cin >> town[i];
        --town[i];
    }
    vector<vector<int>> dp(n,vector<int>(n,INF));
    rep(i,m) {
        int a,b,c;
        cin >> a >> b >> c;
        dp[a-1][b-1]=c;
        dp[b-1][a-1]=c;
    }
    rep(i,n) {
        rep(j,n) {
            rep(k,n) dp[j][k]=min(dp[j][k],dp[j][i]+dp[i][k]);
        }
    }
    int ans=INF;
    sort(town.begin(), town.end());
    do {
        int tans=0;
        rep(i,r-1) tans+=dp[town[i]][town[i+1]];
        ans=min(ans,tans);
    } while (next_permutation(town.begin(), town.end()));
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<functional>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)

using namespace std;

unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main() {

  int n, cnt = 0;
  cin >> n;

  for (int i = 1; i<=n; i++) {
    if(digit(i) % 2 == 1)cnt++;
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 384
import numpy as np

n = int(input())
a = sorted(list(map(int, input().split())))

non_divisible = np.ones(a[-1]+1, dtype=np.int8)
non_divisible[0] = 0
for i in range(n):
    if i != 0 and a[i] == a[i-1]:
        non_divisible[a[i]] = 0
    elif non_divisible[a[i]]:
        non_divisible[a[i]*2::a[i]] = 0

res = 0
for aa in a:
    if non_divisible[aa]:
        res += 1

print(res)


Measured memory_bytes: 51232
n=int(input())
s=[int(input()) for i in range(n)]
k=sum(s)
s1=[i for i in s if i%10==0]
s2=sorted([i for i in s if i%10!=0])

if len(s2)==0:
    print(0)
else:
    if k%10!=0:
        print(k)
    else:
        print(k-s2[0])


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class b{
    public static void Main(){
        string[] str = Console.ReadLine().Split(' ');
        long a = long.Parse(str[0]);
        long b = long.Parse(str[1]);
        long c = long.Parse(str[2]);
        long d = long.Parse(str[3]);
        Console.WriteLine(Math.Max(a*c, Math.Max(a*d, Math.Max(b*c, b*d))));
    }
}


Measured memory_bytes: 17924
#include<stdio.h>
int main()
{
	int N, a[60], i, j, account=0;
	scanf("%d", &N);
	for(i=1; i<=N; i++)
		scanf("%d",&a[i]);
	for(i=1; i<=N; i++)
	{
		for(j=i+1; j<=N; j++)
			account += a[i]*a[j];
	}
	printf("%d", account);
	return 0;
}

Measured memory_bytes: 128
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int D;
int c[26];
int s[366][26];
int last[26];

int main() {
    fastio();

    cin >> D;
    forn(i, 26) cin >> c[i];
    forn1(i, D) forn(j, 26) cin >> s[i][j];

    ll score = 0;
    forn1(i, D) {
        int t;
        cin >> t;
        t--;

        last[t] = i;

        score += s[i][t];
        forn(j, 26) {
            score -= (i - last[j]) * c[j];
        }

        cout << score << endl;
    }

    return 0;
}

Measured memory_bytes: 3684
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer a = Integer.parseInt(scanner.next());

        Integer[] d =  new Integer[a];

        for(int i = 0; i < a; i++) {
            d[i] = Integer.parseInt(scanner.next());
        }
        Arrays.sort(d);

        int half = d.length / 2;
        int start = d[half-1];
        int end = 0;

        if(!(start == d[half])) {
            end = d[half];
            System.out.println(Math.abs(start-end));
        } else {
            System.out.println(0);
        }

    }
}


Measured memory_bytes: 49068
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);

void solve(){
    //7
    string s;
    cin>>s;
    int res=0;
    loop(sz(s),i,0){
        map<char,int>mp;
        loop(sz(s),j,i){
            if(s[j]!='A'&&s[j]!='T'&&s[j]!='C'&&s[j]!='G')
                break;
            mp[s[j]]++;
        }
        int cnt=0;
        for(auto x:mp)
            cnt+=x.s;
        res=max(res,cnt);
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 N;
    cin>>N;
    int64 ans=0;
    if(N<10){
        ans=N;
    }else if (N<100){
        ans=9;
    }else if(N<1000){
        ans=N-90;
    }else if(N<10000){
        ans=9+900;
    }else if(N<100000){
        ans=N-9000-90;
    }else{
        ans=90909;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

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

    int res = N ;
    for(int i = 0; i <= N ; i++){
        int cnt = 0;
        int t = i;
        while (t > 0){
            cnt += t % 6;
            t /= 6;
        }
        t = N - i;
        while (t > 0){
            cnt += t % 9;
            t /= 9;
        }
        if (res > cnt) res = cnt;
    }

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


    return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
if a == b:
    print(a)
else:
    bits = []
    for i in range(b.bit_length()):
        k = pow(2, i+1)
        nb, rb = divmod(b, k)
        na, ra = divmod(max(0,a-1), k)

        bb = nb*(k//2) + max(0, rb - k//2 + 1)
        aa = na*(k//2) + max(0, ra - k//2 + 1)
        bits.append((bb-aa)%2)
    # print(bits)
    print(int(''.join(map(str, bits[::-1])), 2))


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    Vec d(n);
    rep(i,n){
        cin>>d[i];
    }
    ll ans=0;

    rep(i,n-1){
        REP(j,i+1,n){
            ans += d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return  0;
}


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

using int64 = long long;
constexpr static int64 INF = 1e15;

struct Edge {
    int from;
    int to;
    int64 cost;

    Edge(int from, int to, int64 cost)
        : from{from}, to{to}, cost{cost} {}
};

class BellmanFord {
private:
    int V;
    int E;
    std::vector<Edge> es;
    std::vector<int64> d;

public:
    BellmanFord(int V, int E, std::vector<Edge> es)
        : V{V}, E{E}, es{es} {}

    bool find_negative_loop(int s)
    {
        d.assign(V, INF);
        d[s] = 0;

        int cnt = 0;
        bool update = false;
        for (int i = 0; i < V; i++) {
            update = false;
            cnt++;
            for (const Edge &e : es) {
                if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                    if (cnt >= V && e.to == V - 1)
                        return true;

                    update = true;
                }
            }

            if (!update)
                break;
        }

        return false;
    }

    std::vector<int64> calc_shortest_path(int s) {
        if (find_negative_loop(s))
            return {};

        return d;
    }
};

int main()
{
    int N, M;
    std::cin >> N >> M;

    std::vector<Edge> es;
    for (int i = 0; i < M; i++) {
        int a, b;
        int64 c;
        std::cin >> a >> b >> c;
        a--; b--;
        es.emplace_back(a, b, -c);
    }

    BellmanFord bf{N, M, es};
    auto d = bf.calc_shortest_path(0);
    if (d.empty())
        std::cout << "inf" << std::endl;
    else
        std::cout << -d[N - 1] << std::endl;

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    string x,y; cin >> x >> y;

    F0R(i, min(sz(x),sz(y))) {
        cout << x[i] << y[i];
    }

    if (sz(x) == sz(y)) return 0;

    if (sz(x) > sz(y)) {
        cout << x[sz(x)-1];
    } else {
        cout << y[sz(y)-1];
    }

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	

}
int main(){
  
  ll N;
  cin>>N;
  
  vector<ll>A(N+2);
  A[0]=A[N+1]=0;
  ll sum=0;
 for(ll i=1;i<N+1;i++){
    cin>>A[i];
   sum+=abs(A[i]-A[i-1]);
          }
  sum+=abs(A[N]);


  
  for(ll i=1;i<N+1;i++){
    ll normal=abs(A[i-1]-A[i])+abs(A[i]-A[i+1]);
    
    ll delate=abs(A[i-1]-A[i+1]);
    
   cout<<sum+delate-normal<<endl;
  }
}
    
    
    
    
    
    
    

Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
int main(){
	int n;  cin >> n;
	int* arr = new int[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr, arr + n);
	int suma=0, sumb = 0;
	for (int i = 0; i < n; i++)
		if (i % 2 == 0)
			suma += arr[i];
		else
			sumb += arr[i];
	cout << abs(sumb - suma);
		
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define v 500000
#define V 2000000000

int M[v/2+2], S[v/2+2];
int c;
void merge(int T[], int n, int l, int m, int r)
{
  int i,j,k,n1,n2;
  n1 = m-l;
  n2 = r-m;
  for(i=0; i<n1; i++)
    M[i] = T[l+i];
  for(i=0; i<n2; i++)
    S[i] = T[m+i];
  M[n1] = S[n2] = V;
  i = 0;
  j = 0;
  for(k=l; k<r; k++){
    c++;
    if(M[i]<=S[j]) T[k] = M[i++];
    else T[k] = S[j++];
  }
}
void mergeSort(int T[], int n, int l, int r)
{
  int m;
  if(l+1<r){
    m = (l+r)/2;
    mergeSort(T, n, l, m);
    mergeSort(T, n, m, r);
    merge(T, n, l, m, r);
  }
}
int main()
{
  int n,i,T[v];
  scanf("%d",&n);
  c = 0;
  for(i=0; i<n; i++){
    scanf("%d",&T[i]);
  }
  mergeSort(T, n, 0, n);
  for(i=0; i<n-1; i++){
    printf("%d ",T[i]);
  }
  printf("%d\n",T[n-1]);
  printf("%d\n",c);

  return 0;
}



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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

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

const int N = (int)1e5 + 123, mod = (int)1e9 + 7, inf = (int)1e9;


bool was[1000][1000], used[1000][1000];
int n, m, x, y;
int t = 0;
pair<int, int> dir[] = {{0,1},{1,0},{0,-1},{-1,0}};
	
                              
bool good(int x,int y){
	return 0 <= x && x < n && 0 <= y && y < m && !was[x][y];
}

bool good2(int x,int y){
	return !(0 <= x && x < n && 0 <= y && y < m) || !was[x][y];
}

int main(){
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		for(int j = 0; j < m; j++)
			if(s[j] == '#')
				used[i][j] = 1;
	}
	int T = 5e6;
	while(T--){
		was[x][y] = 1;            
		int nx = x + dir[t].f;
		int ny = y + dir[t].s;	
		if(good(nx, ny) && good2(nx + dir[t].f, ny + dir[t].s))
			x = nx, y = ny;
		else
			t = (t + 1) % 4;
		was[x][y] = 1;
	}                
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++)
			if(was[i][j] && !used[i][j])   
				cout << '.';
			else
				cout << '#';
		cout << endl;
	}
	cout << endl;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++)
			if(!was[i][j] && !used[i][j])   
				cout << '.';
			else
				cout << '#';
		cout << endl;
	}

	return 0;
}


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

int main() {
  string s, t; cin >> s;
  const int N = s.size();
  int i;
  rep (i, N) cout << "x";
  cout << endl;

  return 0;
}


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

const int MAX_N = 100;
int N;
int a[MAX_N], b[MAX_N];
int INF = 1<<29;

void solve() {
    int ans = 0;
    a[0] = b[0];
    for(int i = 1; i < N; i++) {
        a[i] = min(b[i-1], b[i]);
    }
    for(int i = 0; i < N; i++) {
        ans += a[i];
    }
    cout << ans << "\n";
    return ;
}

int main() {
    cin >> N;
    for (int i = 0; i < N-1; i++) cin >> b[i];
    b[N-1] = INF;
    solve();
    return 0;
}


Measured memory_bytes: 256
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n>>m;
		ll maxi=1000*n;
	    vi dp(maxi+1,inf);
		vpii bags(n+1,{0,0});
		dp[0]=0;
		rep(i,1,n+1)cin>>bags[i].F>>bags[i].S;

		dp[0]=0;
		rep(i,1,n+1)
		{
			ll w=bags[i].F;
			ll val=bags[i].S;
			bac(j,maxi,val)
			{	
				dp[j]=min(dp[j],dp[j-val]+w);
			}

			//rep(j,0,m+1)cout<<dp[j]<<" ";
			//cout<<endl;
		}
		/*rep(j,1,m+1)
		{
			rep(i,1,n+1)
			{
				if(bags[i].F<=j)
				dp[j]=max(dp[j],dp[j-bags[i].F]+bags[i].S);
			}
		}*/

		ll ans=0;
		rep(i,1,maxi+1)if(dp[i]<=m)ans=max(ans,i);

		cout<<ans<<endl;

    }
    return 0;
        
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int n,a,b;
    cin >> n;
    int x = 0;
    bool r = false;
    for(int i = 0;i<n;i++){
        cin >> a>>b;
        if(a==b){
            x++;
            if(x==3){
                r = true;
            }
        }else{
            x = 0;
        }
    }
    if(r){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}


Measured memory_bytes: 3536
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 9656
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>

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

int main() {
	int n = read(), m = read();
	for(int i = 1,a;i <= m;i++) a = read(), n -= a;
	if(n < 0) std::puts("-1");
	else std::printf("%d\n",n);
	return 0;
}


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

int main() {
    int A,B;
    cin >> A >> B;
    if(A%3==0 || B%3==0 || (A+B)%3==0){
        cout << "Possible" << endl;
        return 0;
    }else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
const int mod = 1e9 + 7; 
int main() {
	int n;
	cin >> n;
	ll fact = 1;
	for (int i = 1; i <= n; i++)
	{
		fact *= i;
		fact %= mod;
	}
	cout << fact << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
}


Measured memory_bytes: 764
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int k,l,x;
  cin >> s >> k;
  set<string> se;
  l=s.size(),x=k;
  k=min(k,l);
  while(k) {
    for(int i=0; i<s.size()-k+1; i++) {
      se.insert(s.substr(i,k));
    }
    k--;
  }
  auto itr=se.begin();
  for(int i=0; i<x-1; i++) {
    itr++;
  }
  cout << *itr << endl;
}

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

using namespace std;

int main(){
  int a,b;
  cin >>  a >> b;

  int x;
  x = 10*b;
  for (int i=x; i<x+10; i++){
    if (i*2/25 == a){
      cout << i<<endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
string s;
  cin >> s;
  int cnt = 0;
  rep(i, s.size() - 1) if (s[i] != s[i + 1]) cnt++;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
ll k, a, b;
int main() {
	cin >> k >> a >> b;
	if (2 <= b - a) {
		if (k < a) {
			cout << 1 + k << endl;
		}
		else {
			ll rest = k - a+1;
			ll ans = a; if (rest % 2)ans++;
			ans += (rest / 2)*(b - a);
			cout << ans << endl;
		}
	}
	else {
		cout << 1 + k << endl;
	}
	//stop
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

double zyou(double m){
	double ans=1;
	rep(i,0,m)ans/=2;
	return ans;
}

int main(){
	double n,m,ans=0;
	cin>>n>>m;
	ans=(100*(n-m)+1900*m)/zyou(m);
	print(ans);
}	

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a+b==15){
    cout << "+" << endl;
  }else if(a*b==15){
    cout << "*" << endl;
  }else{
    cout << "x" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,p=0,i,a;
	scanf("%d",&n);
	map<int,bool> mp;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		if(mp[a]==0)
		mp[a]=1;
		else
		{
			mp[a]=1;
			p=1;
		}
	}
	if(p)
	printf("NO");
	else
	printf("YES");
}

Measured memory_bytes: 9728
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    int pos = 0;  // a[i] + a[i+1] が最大となるi
    rep(i, n-1) {
        if(a[pos] + a[pos+1] < a[i] + a[i+1]) {
            pos = i;
        }
    } 

    // Lがa[pos] + a[pos+1]より大きかったら無理(少なくとも最後に結び目posをほどけないので)
    if(a[pos] + a[pos+1] < L) {
        cout << "Impossible" << endl;
        return 0;
    }

    pos++;  // posを1-indexになおす

    // Lがa[pos] + a[pos+1]の以下の場合は、結び目posを最後まで残しつつ両端から順に結び目をほどけばよい(1,2,…,pos-1 ⇒ n-1,n-2,…,pos+1 ⇒ pos の順)
    cout << "Possible" << "\n";

    for(int i = 1; i < pos; i++) {
        cout << i << "\n";
    }
    for(int i = n-1; i > pos; i--) {
        cout << i << "\n";
    }
    cout << pos << endl;
    
    return 0;
}

Measured memory_bytes: 1664
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]

C = [0] * N
for i in range(N):
    C[i] = sum(AB[i])   
D = sorted(zip(C,range(len(C))),reverse = True)
a = 0
b = 0
for i in range(N):
    if i%2 == 0:a += AB[D[i][1]][0]
    if i%2 == 1:b += AB[D[i][1]][1]
    
print(a-b)

Measured memory_bytes: 42144