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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    //J -> 左回転
    //C -> 右回転
    //E -> 半分にして入れ替え
    //A -> 反転
    //P -> 数字をインクリメント
    //M -> 数字をデクリメント
    int N; cin >> N;
    vector<string> ans;
    rep(i, N){
        string order, recv;
        cin >> order >> recv;
        int lenS = recv.length();
        for(int j = order.length(); j >= 0; j--){
            string temp = "";
            switch(order[j]){
                case 'J':
                    temp += recv[lenS-1];
                    rep(k, lenS-1) temp += recv[k];
                    recv = temp;
                    break;
                case 'C':
                    for(int k = 1; k < lenS; k++) temp += recv[k];
                    temp += recv[0];
                    recv = temp;
                    break;
                case 'E':
                    if((lenS & 1) == 0){
                        for(int k = lenS/2; k < lenS; k++) temp += recv[k];
                        rep(k, lenS/2) temp += recv[k];
                        recv = temp; 
                    }
                    else{
                        for(int k = lenS/2+1; k < lenS; k++) temp += recv[k];
                        temp += recv[lenS/2];
                        rep(k, lenS/2) temp += recv[k];
                        recv = temp; 
                    }
                    break;
                case 'A':
                    reverse(recv.begin(), recv.end());
                    break;
                case 'P':
                    rep(k, recv.length()){
                        if('0' <= recv[k] && recv[k] <= '9'){
                            if(recv[k] == '0') recv[k] = '9';
                            else recv[k]--;
                        }
                    }
                    break;
                case 'M':
                    rep(k, recv.length()){
                        if('0' <= recv[k] && recv[k] <= '9'){
                            if(recv[k] == '9') recv[k] = '0';
                            else recv[k]++;
                        }
                    }
                    break; 
            }
        }
        ans.push_back(recv);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3120
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[110],s,i;
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (i=1;i<=n;i++) s+=a[i];
	if (s%10!=0)
	{
		printf("%d\n",s);
		return 0;
	}
	else
	{
		for (i=1;i<=n;i++)
		{
			if (a[i]%10!=0)
			{
				printf("%d\n",s-a[i]);
				return 0;
			}
		}
		printf("0\n");
	}
}

Measured memory_bytes: 128
from collections import defaultdict
import sys
input = sys.stdin.readline

n, w = map(int, input().split())
obj = [list(map(int, input().split())) for _ in range(n)]

dp = [defaultdict(int), defaultdict(int)]
dp[0][0] = 0
for i in range(n):
    wi, vi = obj[i]
    # print(dp[i%2])
    dp[(i+1)%2] = dp[i%2].copy()
    for w0 in dp[i%2]:
        # dp[(i+1)%2][w0] = dp[i%2][w0]
        if w0 + wi <= w:
            dp[(i+1)%2][w0 + wi] = max(dp[(i+1)%2][w0 + wi], dp[i%2][w0] + vi)

# print(dp[n%2])
print(max(dp[n%2].values()))


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) {
  	cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int alice=0,bob=0;
  for (int i=0; i<N; i++) {
  	if (i % 2 == 0) {
  		alice += a.at(i);
  	} else {
  		bob += a.at(i);
  	}
  }
  cout << alice - bob << endl;
}

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

using namespace std;

void selection_sort(int a[]);
void print(int a[]);

int number=0;
int a[100];
int numberOfSwap=0;

int main(){
    cin>>number;
    for (int i=0; i<number; i++) {
        cin>>a[i];
    }
    selection_sort(a);
    print(a);
    cout<<numberOfSwap<<endl;
}

void selection_sort(int a[]){
    for (int i=0; i<number; i++) {
        int mini = i;
        for (int j=i; j<number; j++) {
            if (a[j]<a[mini]) {
                mini = j;
            }
        }
        if (i!=mini) {
            swap(a[i],a[mini]);
            numberOfSwap++;
        }
    }
}

void print(int a[]){
    for (int i=0; i<number-1; i++) {
        cout<<a[i]<<" ";
    }
    cout<<a[number-1]<<endl;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 20

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

#define SET_MAX 16
#define VAL_MAX 255
#define SAMPLE_MAX 20000
#define ANS_MAX 10000
#define INIT_SAMPLE 128
#define min(a,b) ((a) > (b) ? (b) : (a))
// 522133279
// This is within INT_MAX condidering the worst case;
// // (N: 20000) * (diff_max: 255)*diff_max = 20000 * 65535 <= 1400000000
#define INF 0x1f1f1f1f
#include <limits.h>

int main(void) {
    int ss, ts;
    int ans[ANS_MAX];
    int ans_idx = 0;
    int i, j;
    static int dp[SAMPLE_MAX+1][VAL_MAX+1];
    while(1) {
        get_int2(&ss, &ts);
        if(ss+ts == 0) break;
        int table[SET_MAX];
        int samples[SAMPLE_MAX+1];
        for(i = 0; i < ts; i++) {
            table[i] = get_int();
        }
        for(i = 1; i <= ss; i++) {
            samples[i] = get_int();
        }

        // initialization
        memset(dp, 0x1f, (SAMPLE_MAX+1)*(VAL_MAX+1)*sizeof(int));
        dp[0][128] = 0;
        int prev;
        for(i = 1; i <= ss; i++) {
            int target = samples[i];
            for(j = 0; j < ts; j++) {
                int code = table[j];
                for(prev = 0; prev <= VAL_MAX; prev++) {
                    int cur = prev+code;
                    if(cur < 0) cur = 0;
                    if(cur > VAL_MAX) cur = VAL_MAX;
                    int diff2 = (target - cur)*(target-cur);
                    dp[i][cur] = min(dp[i-1][prev] + diff2, dp[i][cur]);
                }
            }
        }
        int res = INT_MAX;
        for(i = 0; i <= VAL_MAX; i++) {
            res = min(res, dp[ss][i]);
        }
        ans[ans_idx++] = res;
    }
    for(i = 0; i < ans_idx; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 21844
N = int(input())
H = list(map(int, input().split()))

last = H[0]
cnt = 0
max_cnt = 0
for i in range(1, N):
    if last >= H[i]:
        cnt += 1
        if cnt > max_cnt:
            max_cnt = cnt
    else:
        cnt = 0
    last = H[i]
print(max_cnt)


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

using namespace std;

// 無限大の値
const long long INF = 1LL << 60;

// DP テーブル
long long dp[100010];

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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n+1,-1);
    rep(i,n){
        cin >> h[i];
    }
    rep(i,100010) dp[i] = INF;
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        rep(j,k){
            chmin(dp[i+j+1], dp[i] + abs(h[i+j+1] - h[i] ));
        }
    }

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


Measured memory_bytes: 1408
//M Candy

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define INTMAX 1000000000
#define LLMAX 2000000000000000000
#define MOD 1000000007
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VVI vector<VI>
#define alf "abcdefghijklmnopqrstuvwxyz"

int N;
LL a[402], A[402] = {};
LL dp[402][402] = {};//dp[i][j]=[i,j)の塊を区切ったときのコストの最小値

LL solve(int l, int r){
	if(dp[l][r] != LLMAX) return dp[l][r];
	if(l + 1 == r)
		return  dp[l][r] = 0;
	for(int i = l + 1 ; i + 1 <= r; i++){
		dp[l][r] = min(dp[l][r], solve(l, i) + solve(i, r) + A[r - 1] - (l ? A[l - 1] : 0));
	}
	return dp[l][r];
}

int main(){
	cin >> N;
	for(int i=0; i<=N; i++) for(int j=0; j<=N; j++) dp[i][j] = LLMAX;
	for(int i=0; i<N; i++) {
		cin >> a[i];
		A[i] = a[i] + (i ? A[i - 1] : 0);
	}
	cout << solve(0,N) << endl;
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, a, b, s[2100];
int main() {
	cin >> n >> a >> b;
	REP(i, n)cin >> s[i];
	if (n == 1)cout << abs(b - s[0]) << endl;
	else cout << max(abs(s[n - 2] - s[n - 1]), abs(s[n - 1] - b)) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int compare (const void *a, const void *b)
{
    if(*(int64_t *)a - *(int64_t *)b < 0)
        return 1;
    if(*(int64_t *)a - *(int64_t *)b > 0)
        return -1;
    return 0;
}

int main (int argc, char const *argv[])
{
    int64_t N, M, X[(int)1e5];
    int64_t sub[(int)1e5 - 1], ans = 0;

    scanf("%"PRId64"%"PRId64, &N, &M);
    for (int i = 0; i < M; i++) {
        scanf("%"PRId64, &X[i]);
    }

    qsort(X, M, sizeof(int64_t), compare);

    for (int i = 0; i < M; i++) {
        if (i != 0) sub[i - 1] = X[i - 1] - X[i];
    }

    qsort(sub, (M - 1), sizeof(int64_t), compare);

    for(int i = (N - 1); i < M; i++) {
        ans += sub[i];
    }

    printf("%"PRId64"\n", ans);
}


Measured memory_bytes: 2284
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define bit(x) (1LL << x)
#define PI acos(-1.0)
#define EPS 1e-9

#define mod 1000000007
#define maxn 200015

using namespace std;

using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///All indexing is 0-based
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

typedef long long ll;
typedef double ld;
typedef pair<ll, ll> par;


ll sol,A,B,N;

ll calc(ll x)
{
    ll ret = (ll)((A*x) /B) - A* (ll)(x/B);
    sol = max(sol,ret);

    return ret;
}

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> A >> B >> N;

    /*for(int i=1;i<=N;i++)
        cout << i << " " << calc(i) << "\n";*/

    N = min(N,B-1);
    calc(N);
    cout << sol;






}


Measured memory_bytes: 3600
# include <algorithm>
# include <iostream>
# include <cmath>
# include <string>
# include <vector>
#include <numeric>

typedef long long int ll;

using namespace std;

int main() {
    ll N,K,h;
    cin >> N >> K;
    ll H[N+4];
    for (ll i=1; i<=N; i++){
        cin >> h;
        H[i] = h;
    }

    ll dp[N+4];//dp[i]:i番目までのコスト最小値
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(H[2]-H[1]);
    
    for (ll i=3; i<=N; i++){
        ll Min = 10000*N;
        ll Min_candidate;
        for(ll j=1; j<=min(K, i-1); j++){
            Min_candidate = dp[i-j] + abs(H[i]-H[i-j]);
            if (Min_candidate < Min) {
                Min = Min_candidate;
            }
        }
        // cout << "i = " << i << " " << Min << endl;
        dp[i] = Min;
    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string s;
  	cin >> s;
  	bool e = true;
  	int a=s.size();
  	for(int i=0;i<(a/2);i++){
    	if(s.at(i) != s.at(a-1-i)){
        	e = false;
          	break;
        }
    }
  int b = (a-1)/2;
  	for(int i=0;i<(b/2);i++){
      if(s.at(i) != s.at(b-1-i)){
      	e = false;
        break;
      } 
    }
  int c=(a+3)/2;
  for(int i = 0;i<((a-1-c)/2);i++){
  	if(s.at(c+i-1) != s.at(a-1-i)){
    	e=false;
      break;
    }
  }
  if(e==true) cout<<"Yes" <<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n=0;
    scanf("%d", &n);
    int maxnum=0;
    int max=-1;
    for(int i=1;i<=n;i++){
        int sum=0;
        int pres=i;
        while(pres%2==0){
            sum+=1;
            pres/=2;
        }
        if (sum>max){
            maxnum=i;
            max=sum;
        }
    }
    printf("%d", maxnum);
}

Measured memory_bytes: 256
// 2011/09/20 Tazoe

#include <iostream>
#include <queue>
#include <map>
using namespace std;

struct point{
	int y;
	int x;
};

struct state{
	int y;
	int x;
	int t;
};

int main()
{
	int H, W, N;
	cin >> H >> W >> N;

	char M[1002][1002];
	for(int y=0; y<=H+1; y++)
		for(int x=0; x<=W+1; x++)
			M[y][x] = 'X';

	struct point P[10];
	for(int y=1; y<=H; y++){
		for(int x=1; x<=W; x++){
			cin >> M[y][x];
			if(M[y][x]=='S'){
				P[0].y = y;
				P[0].x = x;
				M[y][x] = '.';
			}
			else if(M[y][x]>='1'&&M[y][x]<='9'){
				P[M[y][x]-'0'].y = y;
				P[M[y][x]-'0'].x = x;
				M[y][x] = '.';
			}
		}
	}

	int sum = 0;
	for(int I=0; I<N; I++){
		struct state now;
		now.y = P[I].y;
		now.x = P[I].x;
		now.t = 0;

		queue<struct state> que;
		que.push(now);

		map<int, bool> memo;

		while(true){
			if(que.empty())
				break;

			now = que.front();
			que.pop();

			int yx = now.y*10000+now.x;
			if(memo[yx])
				continue;
			else
				memo[yx] = true;

			if(now.y==P[I+1].y&&now.x==P[I+1].x){
				sum += now.t;
				break;
			}

			struct state nxt = now;
			nxt.y--;
			nxt.t++;
			if(M[nxt.y][nxt.x]=='.')
				que.push(nxt);

			nxt = now;
			nxt.y++;
			nxt.t++;
			if(M[nxt.y][nxt.x]=='.')
				que.push(nxt);

			nxt = now;
			nxt.x--;
			nxt.t++;
			if(M[nxt.y][nxt.x]=='.')
				que.push(nxt);

			nxt = now;
			nxt.x++;
			nxt.t++;
			if(M[nxt.y][nxt.x]=='.')
				que.push(nxt);
		}
	}

	cout << sum << endl;

/*
	for(int y=0; y<=H+1; y++){
		for(int x=0; x<=W+1; x++)
			cout << M[y][x];
		cout << endl;
	}

	for(int i=0; i<=N; i++)
		cout << P[i].y << ' ' << P[i].x << endl;
*/

	return 0;
}

Measured memory_bytes: 15000
# A - Rainy Season
def main():
    s = list(input())
    cnt = 0

    for i in range(3):
        if 'R' == s[i]:
            cnt += 1
        else:
            if cnt == 1:
                print(cnt)
                exit()
    else:
        print(cnt)


if __name__ ==  "__main__":
    main()

Measured memory_bytes: 9044
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

using ll = long long;
const int limit = 100000;
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];
int visited[limit];

void BFS(int v){
  //cout << "first v " << v << endl;
  queue<int> q;
  int i=0;
  visited[v] = 1;
  q.push(v);
  long long d=0;
  while(!q.empty()){
    int val = q.front();
    //cout << "Pop "  << val  << endl;
    for(auto &e : tree[val]){
      //cout << " Next " << e.to << " Cost " << e.cost << endl;
      if(visited[e.to] != 1){
	//cout << "Visited:" <<  e.to << endl;
	d = depth[val] + e.cost;
	//cout << "d:" <<  d << endl;       
	depth[e.to] = d;
	visited[e.to] = 1;
	q.push(e.to);
      }else{
	d = 0;
      }
    }
    q.pop();
  }

}

int main(void) {

  int n;
  cin >> n;

 for (int i=0; i<n-1; i++) {
   int a, b;
   long long c;
   cin >> a >> b >> c;
   a--, b--;
   tree[a].push_back((edge){b, c});
   tree[b].push_back((edge){a, c});
 } 
 
 int q, k;
 cin >> q >> k;
 k--;

 for(int i=0; i<limit; i++){
   visited[i] = 0;
   depth[i] = 0;
 }

 BFS(k);
 
 for(int i=0; i<q; i++){
   int x, y;
   cin >> x >> y;
   x--; y--;
   cout << depth[x] + depth[y] << endl;
 }
 
 return 0;
}


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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);		
		int n=in.nextInt();
		Integer [][] a= new Integer [n][2];
		for(int i=0;i<n;i++)
		{
			a[i][1]=in.nextInt();
			a[i][0]=in.nextInt();
		}
		long ans=0;
		int flag=0;
		Arrays.sort(a, new Comparator<Integer[]>() {
	   	@Override  
		public int compare(Integer[] o1, Integer[] o2) {
	            Integer itemIdOne = o1[0];
	            Integer itemIdTwo = o2[0];
		    return itemIdOne.compareTo(itemIdTwo);
		}
	});
		for(int i=0;i<n;i++)
		{
			ans=ans+a[i][1];
			if(ans>a[i][0])
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
		{
			System.out.println("No");
		}
		else
		{
			System.out.println("Yes");
		}
	}
}
	

Measured memory_bytes: 117068
#include<bits/stdc++.h>
using namespace std;
vector<int>vec[222222];
int n,m,a,b,memo[222222];
int dp(int x){
  int ret=0;
  if(memo[x]!=-1) return memo[x];
  for(int i=0;i<vec[x].size();i++) ret=max(ret,dp(vec[x][i])+1);
  return memo[x]=ret;
}
int main(){
  memset(memo,-1,sizeof(memo));
  int ans=0;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    vec[a].push_back(b);
  }
  for(int i=1;i<=n;i++) ans=max(ans,dp(i));
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 11520
#include<stdio.h>
#include<math.h>
int main(){
	int n;
	scanf("%d",&n);
	long long a[100005];
	a[0]=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	a[n+1]=0;
	int sum=0;
	for(int i=1;i<=n+1;i++){
		sum=sum+abs(a[i]-a[i-1]);
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));
	}
	return 0;
} 

Measured memory_bytes: 1920
#include <iostream> 
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
int a[15][1005];
int sum[15][1005];
int main(int argc, char** argv) {
	int n,m,k;
	cin>>n>>m>>k;
	int vis[13];
	rep(i,1,n)
	{
		rep(j,1,m)
		{
		scanf("%1d",&a[i][j]);	
		sum[i][j]=sum[i][j-1]+a[i][j];
		}
	}
	int ans=1e9;
	rep(i,0,(1<<(n-1))-1)
	{
		int now=0,lst=0,nn=0,uu=0,fg=0;
		rep(kk,0,n-2)if((1<<kk)&i)uu++;
		//if(uu==0)cout<<"?"<<i<<endl;
		rep(j,1,m)
		{nn=0,lst=-10;
			int mx=0;
			rep(kk,0,n-1)
			{
				int f=sum[kk+1][j]-sum[kk+1][now];
				f+=nn;
				mx=max(mx,f);
				nn=f;
				if((1<<kk)&i)
				{nn=0;
				}
			}
			if(mx>k)
			{
				now=j-1;
				uu++;
			}
			mx=0,nn=0,lst=-10;
			rep(kk,0,n-1)
			{
				int f=sum[kk+1][j]-sum[kk+1][now];
				f+=nn;
				mx=max(mx,f);
				nn=f;
				if((1<<kk)&i)
				{nn=0;
				}
			}
			if(mx>k)
			{
				fg=1;
				break;
			}
			
		}
		if(fg)continue;
		//cout<<uu<<endl;
		if(uu<ans)
		{
	//	cout<<i<<"?"<<endl;
		ans=min(ans,uu);
		}
	}
	cout<<ans;
	return 0;
}

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

int n,m;

lli f(int n,int m) {
	if(m%3==0) return 0;
	else return n;
}
lli g(lli n,lli m) {
	lli res=1e18;
	for(int i=1;i<m;i++) {
		lli v1=n*i, v2=(n/2+n%2)*(m-i),v3=n/2*(m-i);
		res = min(res, max(v1,v2) - min(v1,v3));
	}
	return res;
}
int main() {
	scanf("%d%d",&n,&m);

	printf("%lld\n",min({f(n,m),f(m,n),g(n,m),g(m,n)}));
	
	return 0;
}


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

int main(){
	int H, W;
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++){
			for (int k = 0; k < W; k++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

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

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9 + 7;

    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

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

int main(){
    int x1,y1,x2,y2; cin >>x1>>y1>>x2>>y2;
    int x3,y3,x4,y4;
    x3=x2+(y1-y2);
    y3=y2-(x1-x2);
    x4=x3+(x1-x2);
    y4=y3+(y1-y2);
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ar[2][n];
    for(int i = 0; i<2; i++){
        for(int j = 0; j<n; j++){
            cin >> ar[i][j];
        }
    }
    for(int i = 1; i<n; i++){
        ar[0][i] += ar[0][i-1];
    }
    for(int i = n-2; i>=0; i--){
        ar[1][i] += ar[1][i+1];
    }
    int ans = 0;
    for(int i = 0; i<n; i++){
        ans = max(ans,ar[0][i]+ar[1][i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 200005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi;
vector<lln> vl;
vector<pii> vii;
vector<pll> vll;


lln arr[maxii];
lln arr2[maxii];
//bool check[maxii];
bool check2[1000][1000];
//lln n,m;

int main()
{
  string a;
  cin>>a;
  int len=a.size();
  cout<<a[0]<<len-2<<a[len-1];

}






Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std; 

long long int N, A, B;


int main(void) {

	cin >> N >> A >> B;

	long long int tmp = N / (A + B);

	long long int ans = tmp*A;

	ans += min(N - tmp*(A+B), A);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int p[1000],n,k,sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    sort(p,p+n);
    for(int i=0;i<k;i++){
       sum=sum+p[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3612
import math
D,G = map(int, input().split())
pclist = [list(map(int, input().split())) for _ in range(D)]
bits=[format(i, '0'+str(D)+'b') for i in range(2**D)]
ans = 10**5
for bit in bits:
    resn = 0
    res = 0
    maxi = bit.rfind('0')+1
    for i, b in enumerate(bit):
        if b == '1':
            resn += pclist[i][0]
            res += pclist[i][0]*100*(i+1)+pclist[i][1]
    if res >= G:
        if resn < ans:
            ans = resn
    elif maxi > 0 and res+(pclist[maxi-1][0]-1)*100*maxi >= G:
        if G-res > 0:
            resn += math.ceil((G-res)/(100*maxi))
        if resn < ans:
            ans = resn
print(ans)

Measured memory_bytes: 3188
#include<map>
#include<set>
#include<cmath>
#include<climits>
#include<vector>
#include<queue>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
#define mod 1000000007
#define mo 998244353
using namespace std;
#define LL long long int
int main() 
{
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    LL N,K;
    cin >> N >> K;
    vector< pair<LL, LL> > arr;
    for(LL i=0;i<K;i++)
    {
        LL x,y;
        cin >> x >> y;
        arr.push_back({x,y});
    }
    vector<LL> dp(N+1,0);
    dp[1]=1;
    for(LL i=2;i<=N;i++)
    {
        for(auto it:arr)
        {
            if(i-it.first<1)
                continue;
            LL end=i-it.first;
            LL start=max((LL)1,i-it.second);
            dp[i] = (dp[i]+dp[end]-dp[start-1]+2*mo )%mo;
        }
        dp[i]=(dp[i]+dp[i-1])%mo;
    }
    cout<<(dp[N]-dp[N-1]+mo)%mo;
}


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


void solve(long long N, std::vector<std::string> S){
    set<string> a;
    for (int i=0;i<N;i++){
        a.insert(S[i]);
    }
    printf("%d\n",a.size());
    

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int64_t ans = 0;
  
  for(int j=0; j<N; j++){
    int64_t cnt = 0;
    while(vec.at(j) %2 == 0){
      vec.at(j) /= 2;
      cnt++;
    }
    ans += cnt;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
N = int(input())
A = []
A = [input() for _ in range(N)]
print("AC x {}".format(A.count("AC")))
print("WA x {}".format(A.count("WA")))
print("TLE x {}".format(A.count("TLE")))
print("RE x {}".format(A.count("RE")))

Measured memory_bytes: 16256
// 37 38
#include <stdio.h>


void trace(int A[], int N){
	int i;
	for(i=0; i<N; i++){
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N){
	int v, i, j;
	for(i=1;i<N;i++){
		v = A[i];
		j = i-1;
		while(j>=0 && A[j]>v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		trace(A,N);
	}
}

int main(int argc, char const *argv[])
{
	int N, i, j;
	int A[100];

	scanf("%d", &N);

	for(i=0; i<N; i++) scanf("%d", &A[i]);
	trace(A,N);
	insertionSort(A,N);
	

	return 0;
}



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

using namespace std;
typedef long long ll;

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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j;
  
    long double x;
    vector<ll> aa;

    ll Q,N;
    long double a, b;
    string S;
    cin >> S;
    ll flag=0;
    ll t1=0;
    ll t2=0;
  	for(i=0;i<4;i++){
    if(S[i]=='+') {
        ans++;
    }else{
        ans--;
    }
      }
    cout << ans << endl;
      
   
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def solve(N, X, m):
  total = N
  X -= sum(m)
  m.sort()
  total += X // m[0]
  return total


if __name__ == '__main__':
  N, X = map(int, input().split())
  m = [int(input()) for _ in range(N)]
  print(solve(N, X, m))


Measured memory_bytes: 3316
#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>>t;
   int a,b; cin>>a>>b;
   string u; cin>>u;
   if(u==s) cout<<a-1<<" "<<b<<endl;
   else cout<<a<<" "<<b-1<<endl;
   return 0;
}

   


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if(k <= sc.nextInt())
                ans++;
        }
        sc.close();

        System.out.println(ans);
    }
}



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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string u(ty-sy, 'U');
  string d(ty-sy, 'D');
  string l(tx-sx, 'L');
  string r(tx-sx, 'R');
  cout << u << r << d << l;
  cout << 'L' << 'U';
  cout << u;
  cout << 'R' << r;
  cout << 'D' << 'R' << 'D';
  cout << d << l << 'L' << 'U';
  return 0;
}

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

using namespace std;

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    X--;
    Y--;

    vector<int> min(N);
    for (int i = 0; i < N - 1; ++i) {
        for (int j = i + 1; j < N; ++j) {
            int p_ij = j - i;
            int p_iX = X - i < 0 ? -X + i : X - i;
            int p_Yj = Y - j < 0 ? -Y + j : Y - j;
            int m = p_ij < p_iX + 1 + p_Yj ? p_ij : p_iX + 1 + p_Yj;
            min.at(m) = min.at(m) + 1;
        }
    }

    for (int i = 1; i < N; ++i) {
        cout << min.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : kurk.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {

	int a,b;

	cin>>a>>b;

	if(a>b){

		cout <<  "a > b" << endl;

	}else if (a<b){
		cout <<  "a < b" << endl;
	}else{
		cout << "a == b" << endl;
	}
	return 0;
}



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

using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    vector<string> vec;
    string x;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        vec.push_back(x);
    }
    sort(vec.begin(), vec.end());
    for (auto X:vec) cout << X;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] argc){
        Scanner sc = new Scanner(System.in);
        System.out.println(solve(sc));
    }

    public static int solve(Scanner sc){
        int N = sc.nextInt();
        int[] d = new int[N];

        for(int i=0;i<N;i++){
            d[i] = sc.nextInt();
        }
        Arrays.sort(d);
        int cnt = 1;


        for(int i=1;i<N;i++){
            if(d[i] != d[i-1]) cnt++;
        }

        return cnt;
    }
}

Measured memory_bytes: 23764
<?php
list($n) = ints();
for ($i = 0; $i < $n; $i++) {
    list($s[]) = strs();
}
for ($i = 0; $i < $n; $i++) {
    if (isset($a[$s[$i][0]])) $a[$s[$i][0]]++;
    else $a[$s[$i][0]] = 1;
}
$m = ['M', 'A', 'R', 'C', 'H'];
$cnt = 0;
for ($i = 0; $i < 3; $i++) {
    for ($j = $i + 1; $j < 4; $j++) {
        for ($k = $j + 1; $k < 5; $k++) {
            $cnt += ($a[$m[$i]] ?? 0) * ($a[$m[$j]] ?? 0) * ($a[$m[$k]] ?? 0);
        }
    }
}
echo $cnt;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 12920
N, X = map(int, input().split())
L = list(map(int, input().split()))
B=sum(L)
count=1
if X>=B:
  print(len(L)+1)
else:
  i=0
  H=0
  while H<=X:
    H=H+L[i]
    i=i+1
  print(i)

Measured memory_bytes: 3060
import collections
n = int(input())
d = list(map(int, input().split()))
mod = 998244353

if d[0] != 0:
    print(0)
    exit()

cnt = collections.Counter(d)
total = 1
p = 1
if cnt[0] > 1:
    print(0)
    exit()
for i in range(1, n):
    if p == 0 and cnt[i] > 0:
        print(0)
        exit()
    total *= p**cnt[i]
    total %= mod
    p = cnt[i]
print(total % mod)


Measured memory_bytes: 63156
#include<bits/stdc++.h>
#define cmin(a,b) ((a)<(b)?(a):(b))
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
#define rf(i,a,b) for(register int i=(a);i>=(b);i=~(-(i)))
int ans=2e9,n,k,now,x[200010];
int main()
{
	scanf("%d%d",&n,&k);
	f(i,1,n){scanf("%d",&x[i]);if(x[i]>=0&&x[i-1]<0)now=i;}
	if(now==0)
	{
		if(x[1]<0)ans=-x[n-k+1];
		else ans=x[k];
	}
	else
	{
	f(i,now,n)
	{
		if(i-now+1>=k)ans=cmin(ans,x[i]);
		else if(now-(k-(i-now+1))>=1)ans=cmin(ans,x[i]*2-x[now-(k-(i-now+1))]);
	}
	rf(i,now-1,1)
	{
		if(now-i>=k)ans=cmin(ans,-x[i]);
		else if(now+(k-(now-i+1))<=n)ans=cmin(ans,(-x[i]*2)+x[now+(k-(now-i))-1]);
	}}printf("%d\n",ans);
}

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

int main() {
    ll N,L;
    cin >> N >> L;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    ll l=-1,r=-1;
    for(int i=1;i<N;i++){
        if(A[i-1]+A[i]>=L){
            l = i-1;
            r=i;
            break;
        }
    }
    if(l==-1){
        cout << "Impossible" << endl;
        return 0;
    }
    cout <<"Possible" << endl;
    for(int i=0;i<l;i++){
        cout << i+1 << endl;
    }
    for(int j=N-1;j>r;--j){
        cout << j << endl;
    }
    cout << r << endl;


    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        if(i == a[a[i] - 1] - 1)
        {
            ans++;
        }
    }
    cout << ans / 2 << "\n";

    return 0;
}

Measured memory_bytes: 768
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = inp()
memo = [-1] * (s+1)
def dfs(x):
    if memo[x] != -1:
        return memo[x]
    a = 3; b = x-a
    cnt = 0
    res = 0
    while b >= 3:
        cnt += 1
        res += dfs(b)
        res %= mod
        a += 1; b -= 1
    memo[x] = res + cnt
    return res + cnt
ans = dfs(s)
if s >= 3: ans += 1
print(ans)

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

int main(void){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    while(1){
        C = C - B;
        if(C<=0){
            cout << "Yes" << endl;
            return 0;
        }
        A = A - D;
        if(A<=0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
n = int(input()); s = []
for _ in range(n):
  s.append(input())
 
dic = {"AC":0,
       "WA":0,
       "TLE":0,
       "RE":0}

for res in s:
  if res in dic: dic[res] += 1
  
for k in dic:
  print(f"{k} x {dic[k]}")

Measured memory_bytes: 16188
import java.util.*;
class Main {
 
	//最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}
   //整数かどうかを判定する
 static boolean isInteger(double number){return Math.ceil(number) == Math.floor(number); }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		String s = sc.next();
		char[] c = s.toCharArray();

		Long ans = 0l;
		for(int i=0;i<s.length();i++){
			ans += s.charAt(i) - '0';
		}
		
		if(ans%9 == 0){
			System.out.println("Yes");
		} else System.out.println("No");
	}
}

Measured memory_bytes: 45460
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double a;
  cin >> a;
  double b = 100;
  double i = 0;
  double c  = 0;
  while(b < a){
    c = floor(b/100);
    b = b + c;
    i++;
  }
  cout << i << endl;

}

Measured memory_bytes: 3812
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

int main() {
    int K, X;
    cin >> K >> X;

    int left = -1000000;
    int right = 1000000;
    left = max(left, X-K+1);
    right = min(right, X+K-1);
    for (int i = left; i <= right; i++) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import queue
import numpy as np
from scipy import sparse


N, M = list(map(int, input().split()))
links = {}
for i in range(M):
    A, B = list(map(int, input().split()))
    A -= 1
    B -= 1
    if A not in links:
        links[A] = []
    links[A].append(B)

    if B not in links:
        links[B] = []
    links[B].append(A)

que = queue.Queue()
que.put(0)
nearest = np.ones(N, np.int) * -1
while not que.empty():
    p = que.get()
    for q in links[p]:
        if q == 0 or nearest[q] != -1:
            continue
        que.put(q)
        nearest[q] = p

if (nearest[1:] != -1).all():
    print("Yes")
    for i in range(1, N):
        print(nearest[i] + 1)
else:
    print("No")

Measured memory_bytes: 67172
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  int a[11111],b[11111];
  cin>>n;
  int suma=0,sumb=0;
  for(int i=0;i<n;i++)cin>>a[i],suma+=a[i];
  for(int i=0;i<n;i++)cin>>b[i],sumb+=b[i];
  int cnta,cntb,f=0;
  cnta=cntb=sumb-suma;
  //cout<<cnta<<endl;
  for(int i=0;i<n;i++){
    if(a[i]<b[i]){
      cnta-=(b[i]-a[i])/2+(b[i]-a[i])%2;
      cntb-=(b[i]-a[i])%2;
    }
    if(a[i]>b[i]){
      cntb-=(a[i]-b[i]);
    }
  }
  //cout<<cnta<<" "<<cntb<<endl;
  if(cnta<0||cntb<0||cnta*2!=cntb)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 384
s=input()
n=len(s)+1
l=[0]*n
r=[0]*n
for i in range(n-1):
    if s[i]=='<': 
      l[i+1]=l[i]+1
    if s[n-2-i]=='>': 
      r[n-2-i]=r[n-1-i]+1
ans=0
for i in range(n):
  ans+=max(l[i],r[i])
print(ans)


Measured memory_bytes: 27316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int t =700;
  for(int i =0;i < 3;i++){
   if(s.at(i) == 'o'){
     t = t + 100;
   }
  }
  cout << t << endl;
}
    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b+c)%2){
        int d=max(a,max(b,c));
        int e;
        if(d%2==0) e=(d+1)/2*2+1;
        else e=d;
        cout<<(3*e-a-b-c)/2<<endl;
    }
  else{
        int d=max(a, max(b , c));
        int e=(d+1)/2*2;
        cout<<(3*e-a-b-c)/2<<endl;
    }
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>

int main(void)
{
	int kami[10][10];
	int x, y, size;
	int i, j;
	int count;
	int max;
	
	memset(kami, 0, sizeof(kami));
	
	while (scanf("%d,%d,%d", &x, &y, &size) != EOF){
		kami[y][x]++;
		if (size == 3){
			if (x - 2 >= 0){
				x -= 2;
				kami[y][x]++;
				x += 2;
			}
			if (x + 2 < 10){
				x += 2;
				kami[y][x]++;
				x -= 2;
			}
			if (y - 2 >= 0){
				y -= 2;
				kami[y][x]++;
				y += 2;
			}
			if (y + 2 < 10){
				y += 2;
				kami[y][x]++;
				y -= 2;
			}
		}
		if (size >= 2){
			if (x - 1 >= 0 && y - 1 >= 0){
				x--;
				y--;
				kami[y][x]++;
				x++;
				y++;
			}
			if (x + 1 < 10 && y - 1 >= 0){
				x++;
				y--;
				kami[y][x]++;
				x--;
				y++;
			}
			if (x - 1 >= 0 && y + 1 < 10){
				x--;
				y++;
				kami[y][x]++;
				x++;
				y--;
			}
			if (x + 1 < 10 && y + 1 < 10){
				x++;
				y++;
				kami[y][x]++;
				x--;
				y--;
			}
		}
		if (size >= 1){
			if (x - 1 >= 0){
				x--;
				kami[y][x]++;
				x++;
			}
			if (x + 1 < 10){
				x++;
				kami[y][x]++;
				x--;
			}
			if (y - 1 >= 0){
				y--;
				kami[y][x]++;
				y++;
			}
			if (y + 1 < 10){
				y++;
				kami[y][x]++;
				y--;
			}
		}
		
		/*for (i = 0; i < 10; i++){
			for (j = 0; j < 10; j++){
				printf("%d ", kami[i][j]);
			}
			printf("\n");
		}*/
	}
	
	
	count = max = 0;
	for (i = 0; i < 10; i++){
		for (j = 0; j < 10; j++){
			if (kami[i][j] == 0) count++;
			if (max < kami[i][j]) max = kami[i][j];
		}
	}
	
	printf("%d\n", count);
	printf("%d\n", max);
	
	return (0);
}

Measured memory_bytes: 600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int answer = Math.min(Math.min(a+b, b+c), c+a);
        System.out.println(answer);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;
int n,dat[2*MAX-1];

void init(int n_){
    n=1;
    while(n<n_) n*=2;
    for(int i=0;i<2*n-1;i++){
        dat[i]=INF;
    }
}

void update(int k,int a){
    k+=n-1;
    dat[k]=a;
    
    while(k>0){
        k=(k-1)/2;
        dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
}

int query(int a,int b,int k,int l,int r){
    
    if(r<=a||b<=l) return INF;
    if(a<=l&&r<=b) return dat[k];
    else{
        int vl=query(a,b,2*k+1,l,(l+r)/2);
        int vr=query(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
}


int main(){
    
    int N,M;cin>>N>>M;
    string S;cin>>S;
    init(N+1);
    
    update(N,0);
    
    for(int i=N-1;i>=0;i--){
        if(S[i]=='1') continue;
        int mini=query(i+1,min(i+M+1,N+2),0,0,n);
        if(mini!=INF) update(i,mini+1);
    }
    
    if(query(0,1,0,0,n)==INF){
        cout<<-1<<endl;
        return 0;
    }
    
    int now=0;
    vector<int> use;
    while(1){
        int to=now;
        int dis=query(now,now+1,0,0,n);
        while(query(to,to+1,0,0,n)>=dis) to++;
        use.push_back(to-now);
        now=to;
        if(now==N) break;
    }
    
    for(int a:use) cout<<a<<" ";
    cout<<endl;
    
    
}



Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;

  long long int s = 0;
  for (int i = 0; i < n; i++) {
    if ((i + 1) % 3 != 0 && (i + 1) % 5 != 0) s += i + 1;
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 3612
N = gets.to_i

foods = N.times.map { gets.split.map(&:to_i) }

foods.sort_by! { |a, b| a + b }

sumA = 0
sumB = 0
sumC = 0
sumD = 0

N.times do |i|
  a, b = foods[i]

  if i.even?
    sumD += b
    sumA += a
  else
    sumC += a
    sumB += b
  end
end

puts [sumA - sumB, sumC - sumD].max


Measured memory_bytes: 12664
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	vector<int> Ls;
	for (int i = 0; i < n*2; i++)
	{
		int L;
		scanf("%d", &L);
		Ls.push_back(L);
	}
	getchar();
	std::sort(Ls.begin(), Ls.end(), std::greater<int>());
	int ans = 0;
	for (int i = 0; i < n*2; i+=2)
	{
		ans += Ls[i + 1];
	}
	printf("%d\n", ans);
#ifdef _DEBUG
	printf("Press enter to exit\n");
	getchar();
#endif
	return 0;
}


Measured memory_bytes: 256
from collections import Counter


def getinputdata():
    # 配列初期化
    array_result = []

    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if (data != ""):

                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:

        return array_result


arr_data = getinputdata()

n = int(arr_data[0][0])

arr = [int(x) for x in arr_data[1]]
arr_result = [0 for x in range(8)]

cnt = 0
for v in arr:

    if v < 400 *1 :

        arr_result[0] = 1

    elif v < 400 * 2:

        arr_result[1] = 1
    elif v < 400 * 3:

        arr_result[2] = 1
    elif v < 400 * 4:

        arr_result[3] = 1
    elif v < 400 * 5:

        arr_result[4] = 1
    elif v < 400 * 6:

        arr_result[5] = 1
    elif v < 400 * 7:

        arr_result[6] = 1

    elif v < 400 * 8:

        arr_result[7] = 1

    else:

        cnt += 1

if sum(arr_result)!=0:
    print(sum(arr_result), sum(arr_result) + cnt)
else:
    print(1, sum(arr_result) + cnt)


Measured memory_bytes: 3316
pf={}
m=int(input())
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
ans = 0
for v in pf.values():
    now = v
    cou = 1
    while True:
        if now - cou >= 0:
            ans += 1
            now -= cou
            cou += 1
        else:
            break
print(ans)

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;
ll T,n;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m;
    cin >> n >> m;
    ll ans=0;
    if(n>=2)
        ans += (n*(n-1))/2;
    if(m>=2)
        ans += (m*(m-1))/2;
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int w, h, n;
	cin >> w >> h >> n;

	int x, y, a;
	int max_x = 0, min_x = w, max_y = 0, min_y = h; 
	for (int i = 0; i < n; ++i) {
		cin >> x >> y >> a;
		if (a == 1) {
			max_x = max(max_x, x);
		} 
		else if (a == 2) {	
			min_x = min(min_x, x);
		}
		else if (a == 3) {
			max_y = max(max_y, y);
		} else {
			min_y = min(min_y, y);
		}
	}

	if (max_x < min_x && max_y < min_y) {
		cout << (min_x - max_x) * (min_y - max_y) << "\n";
	} else {
		cout << "0\n";
	}

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
int n;
int arr[15],vis[15];
void dfs(int k)
{
	if (k==0)
	{
		for (int i=1;i<=n;i++)
			printf("%c",'a'+arr[i]-1);
		cout<<endl;
	}
	else
	{
		for (int i=1;i<=n;i++)
		{
			if (!vis[i-1])
				return;
			else
			{
				vis[i]++;
				arr[n-k+1]=i;
				dfs(k-1);
				vis[i]--;
			}
		}
	}
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
		arr[i]=1;
	vis[1]=1;
	vis[0]=1;
	dfs(n-1);
} 

Measured memory_bytes: 1536
#include <iostream>
#include <string>
using namespace std;
int min(int a,int b){
    return a < b ? a : b;
}

int main(void){
    string S;
    cin >> S;
    int N = S.length();
    bool is_kaibun = true;
    int middle = (N-1) / 2;
    for(int i=0;i < middle;i++){
        if(S[i] != S[N-i-1]){
            is_kaibun = false;
        }
    }
    
    
    for(int i=0;i < middle / 2;i++){
        if(S[i] != S[middle-i-1] || S[middle+i+1] != S[N-i-1]){
            is_kaibun = false;
        }
    }
    if(is_kaibun){
        cout << "Yes";
    }
    else{
        cout <<"No";
    }
}


Measured memory_bytes: 3128
n=int(input())
A=list(map(int,input().split()))
INF=float('inf')
dp=[-INF]*(n+1)
dp[0]=1000

for i in range(1,n+1):
  dpi=dp[i-1]
  for j in range(1,i):
    dpi=max(dpi,dp[j]+(dp[j]//A[j-1])*(A[i-1]-A[j-1]))
  dp[i]=dpi
  
print(dp[n])

Measured memory_bytes: 64856