akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>

int main() {
  long a, b;

  std::cin >> a >> b;

  if(a > b) {
    std::cout << "a > b" << std::endl;
  }
  else if(a < b) {
    std::cout << "a < b" << std::endl;
  }
  else {
    std::cout << "a == b" << std::endl;
  }    

  return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>
#include<math.h>
#define T 1
#define F 0
#define N 10000
int isprime(int a){
  int i;
  if (a==2)
    return T;
  if (a<2 || a%2==0)
    return F;
  i = 3;
  while (i<= sqrt(a)){
    if (a%i==0)
      return F;
    i = i + 2;
  }
  return T;
}
int main(){
  int a,n,i,count=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a);
    count = count + isprime(a);
  }
  printf("%d\n",count);
  return 0;
} 

Measured memory_bytes: 596
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
  ll n,count=0;cin>>n;
  vll d(1e5+10);
  rep(i,0,n){
    ll tmp;
    cin>>tmp;
    d[tmp]++;
    d[tmp+1]++;
    if(tmp-1>=0)d[tmp-1]++;
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  cout<<d[0]<<endl;
}




Measured memory_bytes: 1152
//package beg_164;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		String[] x = s.nextLine().split(" ");
		
		int a = Integer.parseInt(x[0]);
		int b = Integer.parseInt(x[1]);
		int c = Integer.parseInt(x[2]);
		int d = Integer.parseInt(x[3]);
		
		int diff1 = (int) a/d;
		if (a%d!=0) {
			diff1=diff1+1;
		}
		int diff2 = (int) c/b;
		if (c%b!=0) {
			diff2=diff2+1;
		}
		
		boolean g = diff1>=diff2;
		if (g) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35820
b=input()
a=input().split()
for i in range(0,len(a)):
    a[i]=int(a[i])
b=0
c=0
answer=sum(a)
for i in range(0,len(a)):
    b=b+a[i]
    c=sum(a)-b
    if (b-c>=0 and answer>b-c):
        answer=b-c
    elif (c-b>0 and answer>c-b):
        answer=c-b
print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep01(i, n) for(int i = 0; i < (n) + 1; i++)
#define rep10(i, n) for(int i = 1; i < (n); i++)
#define rep11(i, n) for(int i = 1; i < (n) + 1; i++)
#define all(a) (a).begin(), (a).end()
typedef long long int ll;
typedef struct { int x; int y; } Pos;
using namespace std;
const ll E9P7 = 1000000007; 

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int a = 1; a < n; a++) {
        for (int b = 1; a * b < n; b++) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){

int n;
  cin >> n;
  if(n>=1 && n<2)cout << 1 << endl;
  if(n>=2 && n<4)cout << 2 << endl;
  if(n>=4 && n<8)cout << 4 << endl;
  if(n>=8 && n<16)cout << 8 << endl;
  if(n>=16 && n<32)cout << 16 << endl;
  if(n>=32 && n<64)cout << 32 << endl;
  if(n>=64 && n<=100)cout << 64 << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
#define maxn 3
using namespace std;

struct Node
{
    int x,y;
    int data[maxn][maxn];
    int step;
    friend bool operator ==(Node a,Node b)
    {
        bool flag=true;
        for(int i=0;i<3;i++)
            for(int j=0;j<3;j++)
                if(a.data[i][j]!=b.data[i][j])
                    {
                        flag=false;
                        break;
                    }
        return flag;
    }

    string covert_string()
    {
        string st="";
        for(int i=0;i<3;i++)
            for(int j=0;j<3;j++)
                st+=(data[i][j]-0+'0');
        return st;
    }
};
queue<Node> q;
map<string,int> mp;
int dx[4]={-1,0,0,1};
int dy[4]={0,-1,1,0};

void read(int &x){//读入正整数优化
	char ch = getchar();x = 0;
	for (; ch < '0' || ch > '9'; ch = getchar());
	for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}

int main()
{
    int i,j,k,t,x;
    Node p,p_,aim;
    for(i=0;i<maxn;i++)
        for(j=0;j<maxn;j++)
        {
            read(x);
            p.data[i][j]=x;
            if(x==0)
                p.x=i,p.y=j;
        }
    for(i=0;i<3;i++)
        for(j=0;j<3;j++)
            aim.data[i][j]=(i*3)+j+1;
    aim.data[2][2]=0;
    if(p==aim)
    {
        printf("0\n");
        return 0;
    }
    p.step=0;
    q.push(p);
    mp[p.covert_string()]=1;
    while(!q.empty())
    {
        p=q.front();
        q.pop();
        for(i=0;i<4;i++)
        {
            int xx=p.x+dx[i];
            int yy=p.y+dy[i];
            if(xx>=0&&xx<3&&yy>=0&&yy<3)
            {
                for(j=0;j<3;j++)
                    for(k=0;k<3;k++)
                        p_.data[j][k]=p.data[j][k];
                swap(p_.data[xx][yy],p_.data[p.x][p.y]);
                string st=p_.covert_string();
                if(mp.count(st)==0)
                {
                    p_.x=xx,p_.y=yy,p_.step=p.step+1;
                    if(p_==aim)
                    {
                        printf("%d\n",p_.step);
                        return 0;
                    }
                    q.push(p_);
                    mp[st]=1;
                }
            }
        }
    }
    return 0;
}



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

#define vint vector<int>
#define vvint vector<vint>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}

void Main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(true){
        c -= b;
        if(a <= 0 || c <= 0){
            break;
        }
        a -= d;
        if(a <= 0 || c <= 0){
            break;
        }
    }
    if(a>0){
        ct("Yes");
    }else{
        ct("No");
    }
}

int main() {
    Main();
}


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

struct topnano{char a; int t;};

int main(){
    int n,k=1;
    while(cin>>n){
        if(n==0){break;}
        char c[n],al[30];
        cin>>c[0];
        al[0]=c[0];
        for(int i=1;i<n;i++){
            cin>>c[i];
            for(int j=0;j<k;j++){
                if(al[j]==c[i]){break;}
                else if(j==k-1){
                    al[k]=c[i];
                    k++;
                    break;
                }
            }
        }
        if(k==1){
            cout<<al[0]<<" "<<1+(n/2)<<endl;
        }else{
            int votes[k];
            for(int i=0;i<k;i++){
                votes[i]=0;
            }
            struct topnano ichii,nii;
            ichii.t=0;
            nii.t=0;
            for(int i=0;i<n;i++){
                for(int j=0;j<k;j++){
                    if(c[i]==al[j]){
                        votes[j]++;
                        if(ichii.t<votes[j]){
                            ichii.t=votes[j];
                            ichii.a=al[j];
                        }else if(nii.t<votes[j]){
                            nii.t=votes[j];
                            nii.a=al[j];
                        }
                        break;
                    }
                }
                if(ichii.t > n - i -1+ nii.t){
                    cout<<ichii.a<<" "<<i+1<<endl;
                    break;
                }
                if(i==n-1){
                    if(ichii.t==nii.t){
                        cout<<"TIE"<<endl;
                    }else{
                        cout<<ichii.a<<" "<<i+1<<endl;
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3060
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())

p = t1 * (a1-b1)
n = t2 * (a2-b2)

ans = 0
one = p + n

if one == 0:
    ans = "infinity"


elif one < 0:
    if p > 0:
        ans += (p//(-one)) * 2 + 1
        if p % one == 0:
            ans -= 1

else:
    if p < 0:
        ans += ((-p) // one) * 2 + 1
        if p % one == 0:
            ans -= 1

print(ans)


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

using namespace std;
// using P = pair<long, long>;
using P = pair<double, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

struct Point {
  long x;
  long y;
  long r;
};

struct Edge {
  int to;
  double cost;
};

const int MAX_V = 1005;
vector<Edge> G[MAX_V];
Point R[MAX_V];

int n;
double d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d+MAX_V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            Edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

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

  long xs, ys, xt, yt;
  cin >> xs >> ys >> xt >> yt;

  cin >> n;

  double dist = sqrt(pow(xs - xt, 2.0) + pow(ys - yt, 2.0));
  G[1000].push_back(Edge({1001, dist}));
  G[1001].push_back(Edge({1000, dist}));
  rep(i, n) {
    long x, y, r;
    cin >> x >> y >> r;
    R[i] = Point({x, y, r});
    rep(j, i) {
      double dist = sqrt(pow(R[j].x - x, 2.0) + pow(R[j].y - y, 2.0));
      double cost = max(0.0, dist - R[j].r - r);
      G[i].push_back(Edge({j, cost}));
      G[j].push_back(Edge({i, cost}));
    }
    {
      double dist = sqrt(pow(xs - x, 2.0) + pow(ys - y, 2.0));
      double cost = max(0.0, dist - r);
      G[i].push_back(Edge({1000, max(0.0, dist - r)}));
      G[1000].push_back(Edge({i, max(0.0, dist - r)}));
    }
    {
      double dist = sqrt(pow(xt - x, 2.0) + pow(yt - y, 2.0));
      double cost = max(0.0, dist - r);
      G[i].push_back(Edge({1001, max(0.0, dist - r)}));
      G[1001].push_back(Edge({i, max(0.0, dist - r)}));
    }
  }

  dijkstra(1000);
  printf("%.10f\n", d[1001]);
}


Measured memory_bytes: 21616
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

	int N;
	cin >> N;

	VI L(2 * N);
	REP(i, 2 * N) cin >> L[i];

	SORT(L);
	int ret = 0;
	REP(i, 2 * N) if(i % 2 == 0) ret += L[i];

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int counter = 0;

void KochCurve(int state, int n, double sx, double sy, double ex, double ey)
{
	double x2, y2, x3, y3, x4, y4;
	double angle = atan2((ey - sy), (ex - sx)) + M_PI / 3.0;
	double length = sqrt((sx - ex)*(sx - ex) + (sy - ey)*(sy - ey)) / 3.0;
	x2 = sx + (ex - sx) / 3.0;
	y2 = sy + (ey - sy) / 3.0;
	x3 = x2 + cos(angle)*length;
	y3 = y2 + sin(angle)*length;
	x4 = sx + (ex - sx) / 3.0*2.0;
	y4 = sy + (ey - sy) / 3.0*2.0;

	if (state < n)KochCurve(state + 1, n, sx, sy, x2, y2);
	printf("%lf %lf\n", x2, y2);
	if (state < n)KochCurve(state + 1, n, x2, y2, x3, y3);
	printf("%lf %lf\n", x3, y3);
	if (state < n)KochCurve(state + 1, n, x3, y3, x4, y4);
	printf("%lf %lf\n", x4, y4);
	if (state < n)KochCurve(state + 1, n, x4, y4, ex, ey);
}

int main()
{
	int n;
	double sx = 0.0, sy = 0.0, ex = 100.0, ey = 0.0;
	scanf("%d", &n);

	printf("%lf %lf\n", sx, sy);

	if (n > 0)KochCurve(1, n, sx, sy, ex, ey);

	printf("%lf %lf\n", ex, ey);

	return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<iomanip>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int v[100]={};

	cin >> N;
	for(int i=0;i<N;i++)
		cin >> v[i];
	
	sort(v,v+N);

	double ans=0;
	ans=v[0];
	for(int i=1;i<N;i++)
		ans=(ans+v[i])/2.0;

	cout << fixed << setprecision(7);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int ans = 999;
		for (int i = n; i < 1000; i++) {
			if (i % 111 == 0) {
				ans = i;
				break;
			}
		}

		System.out.println(ans);
		sc.close();
	}

}


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

int main() {
  int n;
  cin>>n;
  vector<long long> l(n+1);
  l[0]=2;
  l[1]=1;
  for(int i=2;i<=n;i++){
    l[i]=l[i-1]+l[i-2];
  }
  cout<<l[n]<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
    if A[i] > B[i]:
        ans += B[i]
        A[i] -= B[i]
        B[i] -= B[i]
    else:
        ans += A[i]
        B[i] -= A[i]
        A[i] -= A[i]
    if A[i+1] > B[i]:
        ans += B[i]
        A[i+1] -= B[i]
        B[i] -= B[i]
    else:
        ans += A[i+1]
        B[i] -= A[i+1]
        A[i+1] -= A[i+1]
print(ans)


Measured memory_bytes: 18752
import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readIntList()
    val A = readIntList()
    val s = A.sum().toDouble()/(4*M)
    println(if (N - A.count{it < s} >= M) "Yes" else "No")
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)


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


int main()
{
    int n,q;
    cin >> n;
    int S[n];
    for(int i = 0; i < n; i++){
        cin >> S[i];
    }
    
    cin >> q;
    int T[q];
    for(int i = 0; i < q; i++){
        cin >> T[i];
    }
    
    int cnt = 0;
    
    for(int i = 0; i < q; i++){
        for(int j = 0; j < n; j++){
            if(S[j] == T[i]){
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(void)
{
        int a,b,c,d,e,f;
        cin>>a>>b>>c>>d>>e>>f;
        double con=0;
        int w,s;
        for(int i=0; i<=30; i++) {
                for(int j=0; j<=30; j++) {
                        for(int y=0; y<=100; y++) {
                                for(int z=0; z<=100; z++) {
                                        int ww=a*i+b*j;
                                        int sw=c*y+d*z;
                                        int total=100*ww+sw;
                                        if(total<=f&&sw<=ww*e) {
                                                if(con<(double)sw/total) {
                                                        con=(double)sw/total;
                                                        w=100*ww;
                                                        s=sw;
                                                }
                                        }
                                }
                        }
                }
        }
        if(con == 0) w= 100*a;
        cout <<w+s<< " " <<s<< endl;
        return 0;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import heapq

def main():
    numbers=[]
    n = int(input())
    [numbers.append(int(input().rstrip())) for _ in range(n)]

    max_n=0
    second_n=0

    for i in numbers:
        if i > max_n:
            max_n=i
        elif i > second_n:
            second_n=i
    
    for i in numbers:
        if i==max_n:
            print(second_n)
        else:
            print(max_n)
    

if __name__=="__main__":
    main()

Measured memory_bytes: 18524
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
int a[12345];
int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    int n,kk;
    cin>>n>>kk;
    int i,j,k;
    vi vec;
    rep(i,n){
    	cin>>a[i];
    }
    int ans=0;
    rep(i,n){
    	f(j,i,n+1){
    		//if(i)
    		vec.clear();
    		rep(k,i){
    			vec.pb(a[k]);

    		}
    		f(k,j,n){
    			vec.pb(a[k]);
    			//cout<<a[k]<<endl;
    		}
    		//cout<<vec.size()<<endl;
    		int moves=vec.size();
    		sort(all(vec));
    		k=0;
    		while(moves<kk && k<vec.size()){
    			if(vec[k]>=0)
    				break;
    			moves++;
    			k++;
    		}
    		int foo=0,bb;
    		//cout<<k<<endl;
    		f(bb,k,vec.size()){
    			foo+=vec[bb];
    		}

    		if(moves>kk)
    			continue;
    		ans=max(ans,foo);
    	}
    }
    cout<<ans<<endl;
    return 0;   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b,c;
 cin >> a >> b >> c;
 if( a <= b && b <= c ){
    cout << a << " " << b << " " << c << endl;
 }else if( b <= c && c <= a ){
    cout << b << " " << c << " " << a << endl;
 }else if( b <= c ){
    cout << b << " " << a << " " << c << endl;
 }else if( a <= b && a <= c ){
    cout << a << " " << c << " " << b << endl;
 }else if( c <= a && a <= b ){
    cout << c << " " << a << " " << b << endl;
 }else{
    cout << c << " " << b << " " << a << endl;
 };
 return 0;
}

Measured memory_bytes: 3076
#include<stdio.h>

int main() {
	int n;
	int result = 0;

	scanf("%d", &n);

	int i_flag, j_flag, k_flag;
	for (int cor = 1; cor <= n; cor++)
	{
		result = 0;
		i_flag = 0, j_flag = 0, k_flag = 0;
		for (int i = 1; i_flag == 0; i++)
		{
			j_flag = 0;
			for (int j = 1; j_flag == 0; j++)
			{
				k_flag = 0;
				for (int k = 1; k_flag == 0; k++)
				{
					int cal = i * i + j * j + k * k + i * j + j * k + k * i;
					if (cal == cor) {
						if (i == j && j == k) {
							result += 1;
						}
						else if (i == j || i == k || j == k) {
								result += 1;
						}
						else {
								result += 1;
						}
					}
					else if (cal > cor) {
						k_flag = 1;
						if (k == 1) {
							j_flag = 1;
							if (j == 1) {
								i_flag = 1;
								printf("%d\n", result);
							}
						}
					}
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2096
H, W, M = map(int, input().split())
S = [tuple(map(int, input().split())) for _ in range(M)]
ss = set(S)

Y = [0] * H
X = [0] * W

for i in range(M):
    y, x = S[i]
    y, x = y-1, x-1
    Y[y] += 1
    X[x] += 1

YM = max(Y)
XM = max(X)

YI = []
for i in range(H):
    if Y[i] == YM:
        YI.append(i)

XI = []
for i in range(W):
    if X[i] == XM:
        XI.append(i)

for y in YI:
    for x in XI:
        if (y+1, x+1) not in ss:
            print(YM+XM)
            exit()
else:
    print(YM+XM-1)

Measured memory_bytes: 192760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const long long INF = 1LL<<60;

int d[10][10];
int cnt[10];

int main() {
    int h,w;
    cin>>h>>w;
    rep(i,10){
        rep(j,10){
            cin>>d[i][j];
        }
    }
    
    rep(i,h){
        rep(j,w){
            int a;
            cin>>a;
            if(a!=-1) cnt[a]++;
        }
    }
    for (int k = 0; k < 10; k++){       // 経由する頂点
        for (int i = 0; i < 10; i++) {    // 始点
            for (int j = 0; j < 10; j++) {  // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    ll ans=0;
    rep(i,10){
        ans+=d[i][1]*cnt[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int x,y,T;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>x>>y;
	for(int C=0;C<=y/2&&C<=x;C++){
		if((y-C*2)%4!=0) continue;
		T=(y-C*2)/4;
		if(C+T==x){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

vector<int> parent;
vector<map<string, int> > child;
vector<bool> isFile;

void addFile(int curr, const string& s, int i)
{
    ++ i;
    if(i >= s.size()){
        isFile[curr] = true;
        return;
    }

    int j = s.find('/', i);
    if(j == string::npos)
        j = s.size();

    string t = s.substr(i, j-i);
    if(child[curr].find(t) == child[curr].end()){
        parent.push_back(curr);
        child.resize(child.size() + 1);
        child[curr][t] = child.size() - 1;
        isFile.push_back(false);
    }

    int next = child[curr][t];
    addFile(next, s, j);
}

int findFile(int curr, const string& s, int i)
{
    if(curr == -1)
        return -1;

    ++ i;
    if(i >= s.size()){
        if(isFile[curr])
            return curr;
        else if(child[curr].find("index.html") != child[curr].end() && isFile[child[curr]["index.html"]])
            return child[curr]["index.html"];
        else
            return -1;
    }

    if(isFile[curr])
        return -1;

    int j = s.find('/', i);
    if(j == string::npos)
        j = s.size();

    string t = s.substr(i, j-i);
    if(t == ".")
        return findFile(curr, s, j);
    else if(t == "..")
        return findFile(parent[curr], s, j);
    else if(child[curr].find(t) != child[curr].end())
        return findFile(child[curr][t], s, j);
    else
        return -1;
}

int main()
{
    for(;;){
        int n, q;
        cin >> n >> q;
        if(n == 0)
            return 0;

        parent.assign(1, -1);
        child.assign(1, map<string, int>());
        isFile.assign(1, false);

        for(int i=0; i<n; ++i){
            string s;
            cin >> s;
            addFile(0, s, 0);
        }

        for(int i=0; i<q; ++i){
            string s, t;
            cin >> s >> t;
            if(s[s.size()-1] == '/')
                s += '.';
            if(t[t.size()-1] == '/')
                t += '.';

            int a = findFile(0, s, 0);
            int b = findFile(0, t, 0);

            if(a == -1 || b == -1)
                cout << "not found" << endl;
            else if(a == b)
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
    }
}

Measured memory_bytes: 1272
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>

const int64_t cc = pow( 10, 9 ) + 7;

bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.second > another.second;
}

int main()
{
    int64_t a,b,c,d;
    std::cin>> a;
    std::cin>> b;

    std::vector< int64_t > ac_s( a, 0 );
    std::vector< int64_t > wa_s( a, 0 );
    std::string aa;
    
    for( int i = 0; i < b; i++ )
    {
        std::cin>> c;
        std::cin>> aa;

        if( aa == "AC" )
        {
            ac_s[c-1] = 1;
        }
        else if( ac_s[c-1] == 0 )
        {
            wa_s[c-1] += 1;
        }
    }

    c = 0;
    d = 0;

    for( int i = 0; i < a; i++ )
    {
        c += ac_s[i];

        if( ac_s[i] == 1 )
        {
            d += wa_s[i];
        }
    }

    std::cout<< c << " " << d <<"\n";
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
int A, B, C;

int main(int argc, char ** argv) {
	scanf("%d%d%d", &A, &B, &C);
	while(C && A > B) B++, C--;
	printf("%d\n", C);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef d
#define d(...)
#endif
#define st first
#define nd second
#define pb push_back
#define siz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
typedef long long LL;
typedef long double LD;
constexpr int INF=1e9+7;
constexpr LL INFL=1e18;
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag,
         tree_order_statistics_node_update>;
*/



int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	auto print = [](int n, set<pair<int, int>>& S) {
		cout << n * (n-1) / 2 - S.size() << "\n";
		for(int i=1; i<=n; i++) {
			for(int j=i+1; j<=n; j++)
				if(not S.count({i, j}))
					cout << i << " " << j << "\n";
		}
		
		exit(0);
	};
	
	int n;
	cin >> n;
	vector<int> pom(n+1);
	int S = n * (n+1) / 2;
	for(int i=1; i<=n; i++)
		pom[i] = S - i;
	
	for(int op = S - n; op >= n; op--) {
		auto sum = pom;
		bool ok = true;
		set<pair<int, int>> forb;
		for(int i=1; i<=n; i++) {
			if(sum[i] == op) continue;
			if(sum[i] - op <= i) {
				ok = false;
				break;
			}
			forb.emplace(i, sum[i] - op);
			sum[sum[i] - op] -= i;
			sum[i] = op;
		}
		
		if(ok) {
			print(n, forb);
		}
	}
			





	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, i, sum=0, t;
    scanf("%lld", &n);
    for(i=1;i<=n;i++) {
        t=(n/i);
        sum=sum+(i*((t*(t+1))/2));
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3672
N, M = map(int,input().split())
L = []
R = []
for i in range(M):
    l, r = input().split()
    L.append(int(l))
    R.append(int(r))

if max(L) <= min(R):
    print(min(R) - max(L) + 1)
else:
    print(0)

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

struct status{
  vector<int> ans;
  vector<long long> last;
};

bool operator< (pair<long long, status> l, pair<long long, status> r){
  if(l.first != r.first) return l.first < r.first;
  return l.first < r.first;
}

int main() {
  int d;
  cin >> d;
  vector<long long> c(26);
  for(int i = 0; i < 26; i++) cin >> c.at(i);
  vector<vector<long long>> s(d, vector<long long> (26));
  for(int i = 0; i < d; i++){
    for(int j = 0; j < 26; j++) cin >> s.at(i).at(j);
  }
  
  priority_queue<pair<long long, status>> beam;
  vector<int> an(0);
  vector<long long> la(26, 0);
  status sta = {an, la};
  beam.push({(long long)0, sta});
  for(int day = 0; day < d; day++){
    priority_queue<pair<long long, status>> now;
    
    while(beam.size() > 0){
      long long score = beam.top().first;
      auto state = beam.top().second;
      beam.pop();
      state.ans.push_back(0);
      
      for(int i = 0; i < 26; i++){
        long long sum = score;
        auto n = state;
        n.last.at(i) = day;
        n.ans.at(day) = i + 1;
        
        sum += s.at(day).at(i);
        for(int j = 0; j < 26; j++){
          sum -= c.at(j) * (day - n.last.at(j));
        }
        
        now.push({sum, n});
      }
    }
    for(int i = 0; i < 270; i++){
      if(now.size() <= 0) break;
      beam.push(now.top());
      now.pop();
    }
  }
  
  auto res = beam.top().second.ans;
  for(auto now : res) cout << now << endl;
}


Measured memory_bytes: 16272
a, b, c = map (int, input().split())
if a < b:
	if a < c:
		if b < c:
			print(a, b, c)
		else:
			print(a, c, b)
	else:
		print(c, a, b)
else:
	if b < c:
		if a < c:
			print(b, a, c)
		else:
			print(b, c, a)
	else:
		print(c, b, a)
		

Measured memory_bytes: 7652
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pi 3.141592653589793
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define vfind(a, e) find(a.begin(), a.end(), e)
#define forr(i, n) for (ll i = 0; i < n; i++)
#define rfor(i, n) for (ll i = n - 1; i >= 0; i--)
#define fors(i, b, e, steps) for(ll i = b; i < e; i += steps)
#define rfors(i, e, b, steps) for(ll i = e; i > b; i -= steps)
#define mp make_pair
using namespace std;


bool isVowel(char c){
    return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}

bool isLower(char c){
    return 97 <= c && c <= 122;
}

bool prime[1001];
void sieve() {
    fill(prime, prime + 1000, 1);
    prime[0] = prime[1] = 0;

    fors(i, 2, 1000, 1) {
        if (prime[i]) {
            fors(j, i * 2, 1000, i) prime[j] = 0;
        }
    }
}

bool f(int a, int b) {
    return a <= b;
}



int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    unordered_map<char, char> d;
    d['A'] = 'T';
    d['T'] = 'A';
    d['C'] = 'G';
    d['G'] = 'C';

    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;

    int dp[n];
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        dp[i] = dp[i - 1];
        if (s[i - 1] == 'A' && s[i] == 'C') {
            dp[i]++;
        }
    }

    while (q--) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        int ans;
        if (l) {
            ans = dp[r] - dp[l - 1];
        }

        else {
            ans = dp[r];
        }

        if (s[l] == 'C' && l - 1 >= 0 && s[l - 1] == 'A') {
            ans--;
        }
        cout << ans << '\n';

    }


}




Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    int L; cin >> L;
    vector<int> a(n);
    int def=0;
    for(int i=0;i<n;i++){
        a[i] = L+i;
        def+=a[i];
    }
    int ans = abs(a[0]);
    int diff=a[0];
    for(int i=1;i<n;i++){
        if(ans>abs(a[i])){
            ans=abs(a[i]);
            diff=a[i];
        }
    }
    //printf("a[0]=%d\n", a[0]);
    //cout << def << " "<<ans<<endl;
    cout << def-diff << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
    int N,i;
    long long int c=0;
    scanf ("%d",&N);
    if (N>=1&&N<=1000000)
    {
        for (i=1;i<=N;i++)
        {
        if (i%3!=0&&i%5!=0)
        {
            c=c+i;
        }
        }
        printf ("%lld\n",c);
    }
    return 0;
}


Measured memory_bytes: 2100
#include <algorithm>
#include <iostream>
#include <queue>
#define N_MAX 30
#define INF (1e9)
using namespace std;
void dijkstra();
int w,h,data[N_MAX][N_MAX],d[N_MAX][N_MAX][4],c[4];
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};
typedef struct stu{
  int mincost,y,x,dir;
  bool operator<(const stu & right)const{
    return mincost>right.mincost;
  }
} dat;

int main(){
  while(1){
    cin>>w>>h;
    if(!w&&!h) break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) cin>>data[i][j];
    for(int i=0;i<4;i++) cin>>c[i];
    dijkstra();
  }
  return 0;
}

void dijkstra(){
  priority_queue<dat > Q;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      for(int k=0;k<4;k++) d[i][j][k]=INF;
  d[0][0][1]=0;
  Q.push((dat){0,0,0,1});
  while(!Q.empty()){
    dat t=Q.top(); Q.pop();
    int cost=t.mincost,y=t.y,x=t.x,dir=t.dir;
    if(cost>d[y][x][dir]) continue;
    for(int i=0;i<4;i++){
      int ny=y+dy[(dir+i)%4],nx=x+dx[(dir+i)%4];
      int ndir=(dir+i)%4;
      if(ny<0||nx<0||h<=ny||w<=nx) continue;
      if(d[ny][nx][ndir]>cost+c[i]){
	d[ny][nx][ndir]=cost+c[i];
	Q.push((dat){d[ny][nx][ndir],ny,nx,ndir});
      }
      if(data[y][x]!=i) continue;
      if(d[ny][nx][ndir]>cost){
	d[ny][nx][ndir]=cost;
	Q.push((dat){d[ny][nx][ndir],ny,nx,ndir});
      }
    }
  }
  int mincost=INF;
  for(int i=0;i<4;i++)
    mincost=min(mincost,d[h-1][w-1][i]);
  cout<<mincost<<endl;
}

Measured memory_bytes: 1356
#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
const int inf = 1 << 30;
const int INF = INT_MAX;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d;
  cin >> d;
  cout << "Christmas";
  for (int i = 24; i >= d; --i) {
    cout << " Eve";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 892
def main():
    n,k,*a=map(int,open(0).read().split())
    for _ in range(k):
        b=[0]*n
        m=10**18
        for i,t in enumerate(a):
            if t<m:m=t
            b[max(0,i-t)]+=1
            if i-~t<n:b[i-~t]-=1
        if m>=n:break
        for i in range(n-1):b[i+1]+=b[i]
        a=b
    print(' '.join(map(str,a)))
main()

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

class Main {
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String str[] = br.readLine().split(" ");

        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);

        char mat[][] = new char[n][m];
        int start[][] = new int[n][m];
        int end[][] = new int[n][m];

        for(int i = 0; i < n; i++) {
            char c[] = br.readLine().toCharArray();
            for(int j = 0; j < m; ++j) {
                mat[i][j] = c[j];
            }
        }

        int rows[][] = new int[n][m+2];
        int cols[][] = new int[m][n+2];

        
        // for(int i = 0; i < n; i++) {
        //     rows[i] = new Vector<Integer>();
        // }

        // for(int i = 0; i < m; i++) {
        //     cols[i] = new Vector<Integer>();
        // }

        int ans = 0;

        for(int i = 0; i < n; i++) {
            int cnt = 0;

            rows[i][cnt++] = -1;
            for(int j = 0; j < m; j++) {
                if(mat[i][j] == '#') {
                    rows[i][cnt++] = j;
                }
            }
            rows[i][cnt++] = m;

            int l = 0, r = 1;

            for(int j = 0; j < m; j++) {
                if(mat[i][j] != '#') {
                    start[i][j] = rows[i][r] - rows[i][l];
                }
                else {
                    start[i][j] = 0;
                }
                if(j == rows[i][r]) {
                    l = r;
                    r += 1;
                }
            }
        }

        for(int i = 0; i < m; i++) {
            int cnt = 0;
            cols[i][cnt++] = -1;
            for(int j = 0; j < n; j++) {
                if(mat[j][i] == '#') {
                    cols[i][cnt++] = j;
                }
            }
            cols[i][cnt++] = n;

            int l = 0, r = 1;
            for(int j = 0; j < n; j++) {
                if(mat[j][i] != '#') {
                    end[j][i] = cols[i][r] - cols[i][l];
                }
                else {
                    end[j][i] = 0;
                }
                if(j == cols[i][r])  {
                    l = r;
                    r += 1;
                }
            }
        }

        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                ans = Math.max(ans, (start[i][j] + end[i][j]));
            }
        }

        System.out.println(ans - 3);
    }
} 

            

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

using namespace std;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vl vector<ll>
#define pb push_back
#define mod 1000000007 
#define N 10000000
#define all(a) a.begin(),a.end()
#define point pair<int,int>
const int inf = 1000000007;
const ll linf = 1ll * inf * inf;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};


int main()
{
	fio;
	ll t;t=1;
	while(t--)
	{
		ll n;cin>>n;
		vl a(n);
		f(n)cin>>a[i];
		vvl dp(n,vl(n,LLONG_MAX));
		ll pre[n];
		pre[0]=a[0];
		for(ll i=1;i<n;i++)pre[i]=pre[i-1]+a[i];
		f(n)dp[i][i]=0;
		for(ll k=1;k<n;k++)
		{
			for(ll i=0;i+k<n;i++)
			{
				ll j=i+k;
				for(ll m=i;m<j;m++)
				{
					if(i>0){
						ll sum=pre[j]-pre[i-1];
						dp[i][j]=min(dp[i][j],dp[i][m]+dp[m+1][j]+sum);
					}
					else{
						ll sum=pre[j];
						dp[i][j]=min(dp[i][j],dp[i][m]+dp[m+1][j]+sum);
					}
				}
			}
		}
		cout<<dp[0][n-1]<<"\n";
	}
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=2e4+7;
int dp[maxn];
int main()
{
    int h,n;
    cin>>h>>n;
    memset(dp,0x3f,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        for(int j=a;j<maxn;j++)
            dp[j]=min(dp[j],dp[j-a]+b);
    }
    int ans=0x3f3f3f3f;
    for(int j=h;j<maxn;j++) ans=min(ans,dp[j]);
    cout<<ans<<'\n';
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
int a[4];
int b[4];
int hit=0,blow=0;
while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
	hit=0;
	blow=0;
cin>>b[0]>>b[1]>>b[2]>>b[3];
for(int i=0;i<4;i++){
if(a[i]==b[i])hit++;}
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
if(a[i]==b[j])blow++;}}
blow-=hit;
cout<<hit<<" "<<blow<<endl;}}

Measured memory_bytes: 0
//ABC141 A
import java.util.Scanner;
public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    String S;
    S=sc.nextLine();
    String s="Sunny";
    String c="Cloudy";
    String r="Rainy";

    if(S.equals(s)){
      System.out.println("Cloudy");
    }else if(S.equals(c)){
      System.out.println("Rainy");
    }else{
      System.out.println("Sunny");
    }

  }
}


Measured memory_bytes: 20820
n = int(input())
s = input()
l = [0]*(n+1)
count = 0
for i in range(len(s)) :
    if s[i] == "." :
        count += 1
    l[i+1] = count
siro = l[-1]
ans = 1000000000000000000000
for i in range(n+1):
    ans = min(ans,i-2*l[i]+siro)
print(ans)

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

typedef long double ld;
#define int long long   
#define PB push_back 
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int> 
#define vii vector< ii >
#define F first
#define S second 
#define mem1(a) memset(a,-1,sizeof(a))
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
ld pi= 3.14159265358979;
//const int mod=998244353; 
const int mod = 1e9+7;
const int N=2e5+5;

mii mp;
void primeFactors(int n)  
{  
    while (n % 2 == 0)  
    {  
        mp[2]++;  
        n = n/2;  
    }  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    { 
        while (n % i == 0)  
        {  
            mp[i]++;
            n = n/i;  
        }  
    }  
    if (n > 2)  
        mp[n]++;  
}
void solve()
{   
    int n; cin>>n;
	int ans=0;
	primeFactors(n);
	for(auto i : mp){
		int x  = i.S;
		int cnt=1;
		while(x){
			if(x < cnt) x = 0;
			else{
				x-=cnt++; ans++;
			}
		}
	}
	cout<<ans;        
}

signed main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  //  cout<<setprecision(20);
    int tc=1; //cin>>tc;
    while(tc--){
        solve();cout<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3672
/*
Hanit Banga
*/

#include <iostream>
#include <vector>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

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

const int N = 55;

string a[N], b[N];

bool match(int sx, int sy, int m);

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

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

	for (int i = 0; i < m; ++i)
		cin >> b[i];	

	for (int i = 0; i < n - m + 1; ++i)
	{
		for (int j = 0; j < n - m + 1; ++j)
		{
			if (match(i, j, m))
			{
				cout << "Yes";
				return 0;
			}
		}
	}

	cout << "No";
}

bool match(int sx, int sy, int m)
{
	for (int i = 0; i < m; ++i)
		for (int j = 0; j < m; ++j)
			if (b[i][j] != a[sx + i][sy + j])
				return false;

	return true;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct UnionFind {
    UnionFind() {}
    UnionFind(int n) {
        resize(n);
    }
    
    void resize(int n) {
        par.resize(n, -1);
    }
    
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    
    bool merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
    
    int size(int x) {
        return -par[root(x)];
    }
    
private:
    vector<int> par;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    set<int> roots;
    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        uf.merge(x, y);
    }
    rep(i, n) {
        roots.insert(uf.root(i));
    }
    cout << (sz(roots)) << endl;
    return 0;
}


Measured memory_bytes: 5376