akhauriyash/Code-Regression huggingface dataset:
// ABC176E - Bomber
 
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long int ull;
typedef long long int ll;
 
int main() {
	int H, W, M;
	cin >> H >> W >> M;

	int h[M], w[M];
	map<int, int> row;
	map<int, int> col;
	set<pair<int,int>> bomb;
	for (int i = 0; i < M; i++) {
		cin >> h[i] >> w[i];
		row[h[i]]++;
		col[w[i]]++;
		bomb.insert(make_pair(h[i], w[i]));
	}

	int r_max = 0;
	for (int i = 1; i <= H; i++) {
		if (r_max < row[i]) {
			r_max = row[i];
		}
	}
	int c_max = 0;
	for (int i = 1; i <= W; i++) {
		if (c_max < col[i]) {
			c_max = col[i];
		}
	}

	set<int> r_max_num;
	for (int i = 1; i <= H; i++) {
		if (r_max == row[i]) {
			r_max_num.insert(i);
		}
	}
	set<int> c_max_num;
	for (int i = 1; i <= W; i++) {
		if (c_max == col[i]) {
			c_max_num.insert(i);
		}
	}

	if (r_max_num.size() * c_max_num.size() > M) {
		cout << r_max + c_max << endl;
		return 0;
	}

	for (set<int>::iterator i = r_max_num.begin(); i != r_max_num.end(); i++) {
		for (set<int>::iterator j = c_max_num.begin(); j != c_max_num.end(); j++) {
			if (bomb.find(make_pair(*i, *j)) == bomb.end()) {
				cout << r_max + c_max << endl;
				return 0;
			}
		}
	}

	cout << r_max + c_max - 1 << endl;

	return 0;
}


Measured memory_bytes: 76264
def main():
    point_count = int(input())
    sums = []
    diffs = []
    for _ in range(point_count):
        x, y = [int(x) for x in input().split()]
        sums.append(x + y)
        diffs.append(x - y)
    pat_sum = max(sums) - min(sums)  # max (Xi + Yi) - (Xj + Yj)
    pat_diff = max(diffs) - min(diffs)  # max (Xi - Yi) - (Xj - Yj)
    return max(pat_sum, pat_diff)


if __name__ == '__main__':
    print(main())


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

constexpr int mod = 1000000007;
class mint {
 public:
  long long x;
  constexpr mint(long long x = 0) : x((x % mod + mod) % mod) {}
  constexpr mint operator-() const { return mint(-x); }
  constexpr mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr mint& operator-=(const mint& a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr mint& operator*=(const mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  constexpr mint operator+(const mint& a) const {
    mint res(*this);
    return res += a;
  }
  constexpr mint operator-(const mint& a) const {
    mint res(*this);
    return res -= a;
  }
  constexpr mint operator*(const mint& a) const {
    mint res(*this);
    return res *= a;
  }
  constexpr mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  constexpr mint inv() const { return pow(mod - 2); }
  constexpr mint& operator/=(const mint& a) { return (*this) *= a.inv(); }
  constexpr mint operator/(const mint& a) const {
    mint res(*this);
    return res /= a;
  }
};
ostream& operator<<(ostream& os, const mint& m) {
  os << m.x;
  return os;
}

int main() {
  int n;
  cin >> n;
  vector<mint> a(n);
  for (int i = 0; i < n; ++i) {
    long long inp;
    cin >> inp;
    a[i] = inp;
  }
  mint msum = 0;
  mint mans = 0;
  for (int i = 0; i < n-1; ++i) {
    msum = msum + a[i];
    mans +=  msum * a[i+1];
  }
  cout << mans << endl;
}



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

int main()
{
   int n;
   cin >> n;
   if (n == 0)
   {
      cout << "1" << endl;
   }
   else
   {
      cout << "0" << endl;
   }
}

Measured memory_bytes: 3604
#include <iostream>


using namespace std;

int main()
{
	while(true)
	{
		int H, W;
		cin >> H >> W;
		if(H == 0 && W == 0)
		{
			return 0;
		}
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				if((i + j) % 2 == 0)
				{
					cout << "#";
				}
				else
				{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
a,b,c = map(int,input().split())
mod = a%b

if mod == c:
    print("YES")
else:
    i = 2
    flag = 0
    while (mod*i)%b != mod:
        if (mod*i)%b == c:
            flag = 1
            break
        i += 1
    if flag == 1:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 39336
def resolve():
    import heapq
    n, m = map(int, input().split())
    a = list(map(lambda x:int(x)*-1, input().split()))
    heapq.heapify(a)
    for i in range(m):
        maxa = heapq.heappop(a) * -1
        maxa //= 2
        heapq.heappush(a, -maxa)
    print(sum(a)*-1)
resolve()

Measured memory_bytes: 72088
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#define PI 3.14159265358979323846264338327950288
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
typedef long long ll;
using namespace std;
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)

int main(void) {

	long double A, B;
	cin >> A >> B;
	cout << (ll)(A * B) << endl;
	return 0;
}


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


void solve(long long H, long long A){
    int x=0;
    while(H > 0)
    {
        H = H - A;
        x++;
    }
    cout << x << endl;
}

// 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 H;
    scanf("%lld",&H);
    long long A;
    scanf("%lld",&A);
    solve(H, A);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;

int main()
{
	string S;
	cin >> S;
	int n = ceil(S.size() / 2),ans = 0;
	vchar s(n);
	vchar t(S.size()-n);
	for(int i = 0;i<n;i++)
	{
		s[i] = S[i];

	}
	for(int i = 0;i<n;i++)
	{
		if (S[S.size()-1-i] != s[i])
		{
			ans++;
		}
	}
	cout << ans;
}


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

int main(){
	int N, n, s = 0;
	cin >> N;
	n = N;
	for(int i = 0; n != 0; i++){
		s += n % 10;
		n /= 10;
	}
	if(N % s == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int N){
    vector<int>S;
    rep(i,N)if(bit & (1<<i))S.push_back(i);
    return S;
}

int main(){
    int n;cin>>n;
    vector<int>v(n);
    rep(i,n)v[i] = i+1;
    VEC(int,p,n);
    VEC(int,q,n);
    int a,b;
    int cnt = 0;
    do{
        cnt++;
        int c1 = 0,c2 = 0;
        rep(i,n){
            if(v[i]==p[i])c1++;
            if(v[i]==q[i])c2++;
        }
        if(c1==n)a = cnt;
        if(c2==n)b = cnt;
    }while(next_permutation(ALL(v)));
    cout<<abs(a-b);
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long numA = scan.nextLong();
		String strS = scan.next();

		String result = "red";

		if (numA >= 3200) {
			result = strS;
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

struct UnionFind {
  vector<int> par;

  UnionFind(int N) : par(N) {
    for (int i = 0; i < N; i++) {
      par[i] = i;
    }
  }

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

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) {
      return;
    }
    par[rx] = ry;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

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

  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }

  UnionFind uf(n);

  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);

    uf.unite(x - 1, y - 1);
  }

  int count = 0;
  for (int i = 0; i < p.size(); i++) {
    if (uf.same(i, p[i] - 1)) {
      count++;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll x[105], y[105], h[105];

int getH(int cx, int cy, int x, int y, int h)
{
	return h + abs(cx - x) + abs(cy - y);
}

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> x[i] >> y[i] >> h[i];
	}

	REP(cx, 101)
	{
		REP(cy, 101)
		{
			int sh = -1;
			int min = 2000000000;
			bool f = true;
			REP(i, N)
			{
				if (h[i] == 0)
				{
					min = std::min(min, getH(cx, cy, x[i], y[i], h[i]));
				}
				else
				{
					int th = getH(cx, cy, x[i], y[i], h[i]);
					if (sh == -1)
					{
						sh = th;
					}
					else
					{
						if (sh != th)
						{
							f = false;
						}
					}
				}
				if (!f)break;
			}

			if (f)
			{
				if (sh <= min)
				{
					cout << cx << " " << cy << " " << sh << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    string s;
    cin >> s;
    bool judge = true;
    for(int i = 0; i < s.size() - 1; i++){
        if(s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << " "<< endl;
            return 0;
        }
    }
    for(int i = 0; i < s.size() - 2; i++){
        if(s[i] == s[i + 2]){
            cout << i + 1 << " " << i + 3 << " " << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << " "  << endl;
}


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

int main() {
  string s;
  cin >> s;
  if (s.size() > 2){
    cout << s.at(0) << s.size() - 2 << s.at(s.size() - 1) << endl;
  }
  else cout << s << endl;
}

Measured memory_bytes: 256
I = input()
I = I.split(" ")
N = int(I[0])
K = int(I[1])
Q = int(I[2])

A = [0] * Q

for i in range(Q):
	A[i] = int(input())

point = [0] * N

for i in range(Q):
	point[A[i]-1] = point[A[i]-1] + 1

for i in range(N):
	if Q - point[i] < K:
		print("Yes")
	else:
		print("No")


Measured memory_bytes: 8636
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int X = scan.nextInt();
      int N = scan.nextInt();
      int pn[] = new int[N];
      for(int i=0; i<N; i++){
        pn[i] = scan.nextInt();
      }
      int ans1 = X;
      int ans2 = X;
      int x = X;
      
      while(true){
        for(int i=0; i<N; i++){
           if(x == pn[i]){
             ans1 = 200;
             break;
           }else
             ans1 = x;
        }
        if(ans1 == x)
          break;
        x -= 1;
      }
      x = X;
      while(true){
        for(int i=0; i<N; i++){
           if(x == pn[i]){
             ans2 = 200;
             break;
           }else
             ans2 = x;
        }
        if(ans2 == x)
          break;
        x += 1;
      }
      
      if(X-ans1 > ans2-X)
        System.out.println(ans2);
      else
        System.out.println(ans1);
   }
}

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

int a[7];
int e=0;

void move(char i){
int b[7];
for(int n=1;n<7;n++){b[n]=a[n];}

if(i=='W'){
a[6]=b[4];
a[4]=b[1];
a[1]=b[3];
a[3]=b[6];
}

if(i=='N'){
a[6]=b[5];
a[5]=b[1];
a[1]=b[2];
a[2]=b[6];
}

if(i=='E'){
a[6]=b[3];
a[3]=b[1];
a[1]=b[4];
a[4]=b[6];
}

if(i=='S'){
a[6]=b[2];
a[2]=b[1];
a[1]=b[5];
a[5]=b[6];
}

if(i=='R'){
a[3]=b[2];
a[2]=b[4];
a[4]=b[5];
a[5]=b[3];
}}





int main(){
int c[7];
string t="NWSWSWRRRRNNNEEESESWNRRRSREWNNNSERSRWNNWWWNNNNSRSREWNSNNSNWNNWNENENRNENNWWWESWESRESWSERSRSEWSWESRRWEWREWW";
for(int h=1;h<7;h++){cin>>a[h];}
for(int h=1;h<7;h++){cin>>c[h];}

for(int g=0;g<105;g++){
for(int l=1;l<7;l++){
if(l==6 && a[l]==c[l]){e=1;}
if(a[l]==c[l]){continue;}
break;
}
if(e==1){break;}
move(t[g]);
}

if(e==1){cout<<"Yes"<<endl;}
if(e==0){cout<<"No"<<endl;}

return 0;
}


Measured memory_bytes: 3176
#include<stdio.h>
int main(){
  int i,j,n,x,y,z;
  scanf("%d",&n);
  int g[n][n];
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      g[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&x,&y);
    x--;
    for(j=0;j<y;j++){
      scanf("%d",&z);
      z--;
      g[x][z]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
	if(j!=0)printf(" ");
	printf("%d",g[i][j]);
      }
    printf("\n");
  }
	  
  return 0;
}



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

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

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

	ll sum[2] = {0};
	ll ans[2] = {0};

	rep(i, n){
		int a;
		cin >> a;

		rep(j, 2){
			sum[j] += a;
			if((i + j) % 2){
				if(sum[j] >= 0){
					ans[j] += sum[j] + 1;
					sum[j] = -1;
				}
			}else{
				if(sum[j] <= 0){
					ans[j] += -sum[j] + 1;
					sum[j] = 1;
				}
			}
		}
	}

	cout << (ans[0] < ans[1] ? ans[0] : ans[1]) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def main():

        H, W = map(int, input().split())
        grid = [[_ for _ in input()] for _ in range(H)]
        for h in range(H):
            for w in range(W):
                if grid[h][w]=='#':
                    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
                        nh, nw = h + j, w + k
                        # nh と nw が街の範囲を超えてたら後の処理をスキップして別方向を模索
                        if nh < 0 or nh >= H or \
                                nw < 0 or nw >= W:
                            continue
                        else:
                            if grid[nh][nw] == '#':
                                break
                            else:
                                if [j, k] == [0, -1]:
                                    return 'No'
        return 'Yes'

    print(main())


resolve()

Measured memory_bytes: 40176
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for k in range(a+1):
    for j in range(b+1):
        for i in range(c+1):
            total = 500*k + 100*j + 50*i
            if total == x:
                count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>

#define MAX 100002
#define INF 2000000000

using namespace std;

typedef struct {
    int num;
    string suit;
    int ID;
} Card;

Card LEFT[MAX/2 + 2],RIGHT[MAX/2 + 2];

void comb(Card A[],int left,int mid,int right){
    int n1,n2;
    n1 = mid - left;
    n2 = right - mid;
    for (int i = 0; i < n1; i++) LEFT[i] = A[left + i];
    for (int i = 0; i < n2; i++) RIGHT[i] = A[mid + i];
    
    LEFT[n1].num = INF;
    RIGHT[n2].num = INF;
    
    int N = n1 + n2;
    int count_l=0,count_r=0;
    
    for (int i = 0; i < N; i++) {
        if (LEFT[count_l].num <= RIGHT[count_r].num) {
            A[left + count_l + count_r] = LEFT[count_l];
            count_l++;
        }else{
            A[left + count_l + count_r] = RIGHT[count_r];
            count_r++;
        }
    }
}

void MegeSort(Card A[],int left,int right){
    //cout << "Merge" << endl;
    int mid = (left + right)/2;
    if (right - left > 1) {
        MegeSort(A,left,mid);
        MegeSort(A,mid,right);
        comb(A,left,mid,right);
    }
}

int partition(Card A[],int left,int right){
    int index=0;
    int a = left;
    for (int i = left; i < right; i++) {
        if (A[i].num <= A[right - 1].num) {
            Card c = A[i];
            A[i] = A[a];
            A[a] = c;
            a++;
            index = a;
        }
    }
    return index;
}

void quicksort(Card A[],int left,int right){
    //cout << "quick" << endl;
    int index = partition(A,left,right);
    if (index - 1 - left > 1) {
        quicksort(A,left,index - 1);
    }
    if (right - index > 1) {
        quicksort(A,index,right);
    }
}

int main(){
    int n;
    scanf("%d",&n);
    Card A[MAX+1];
    Card B[MAX+1];
    for (int i=0; i < n; i++) {
        char k[2];
        scanf("%s %d",k,&A[i].num);
        A[i].suit = k;
        A[i].ID = i;
        B[i]=A[i];
    }

    quicksort(A,0,n);
    MegeSort(B,0,n);
    int flag=0;
    for (int i = 0; i < n; i++) {
        if (B[i].ID != A[i].ID) {
            flag = 1;
            break;
        }
    }
    if (flag == 1) {
        cout << "Not stable" << endl;
    }else{
        cout << "Stable" << endl;
    }
    for (int i = 0; i < n; i++) {
        cout << A[i].suit << " " << A[i].num << endl;
    }
    
    return 0;
}

Measured memory_bytes: 12944
#include <iostream>

using namespace std;

int main() {
	int a;
	cin >> a;
	int cnt = 0;
	if((a / 100) == 1) cnt++;
	if((a / 10) % 10 == 1) cnt++;
	if(a % 10 == 1) cnt++;
	cout << cnt << endl;
	return 0;
}


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

int main(void){
  int a, b, c, d;

  cin >> a >> b >> c >> d;
  
  if((std::abs(a-b)<=d && std::abs(b-c)<=d) || std::abs(a-c)<=d) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 384
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i32 n;
cin >> n;
vector<i32> h(n);
rep(i,n)cin >> h[i];
vector<i32> dp(n,1e9);
dp[0] = 0;
for(i32 i = 1; i <= n; i++){
    dp[i] = min(dp[i],dp[i - 1] + abs(h[i] - h[i - 1]));
    if(i > 1)dp[i] = min(dp[i],dp[i - 2] + abs(h[i] - h[i - 2]));
}
cout << dp[n - 1] << endl;
}

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

int main(){
  int a , b;
    cin >> a >> b;
  
  if( a*b % 2 == 0) {
    cout << "Even" << endl;
  }
  if( a*b % 2 == 1) {
    cout << "Odd" << endl;
  }
}
    

Measured memory_bytes: 3568
require 'pp'

N,C=gets.chomp.split(' ').map{|n| n.to_i}
targets = []
1.upto(N){|i|
	targets << gets.chomp.split(' ').map{|n| n.to_i}
}
targets = targets.sort{|a,b| a[0] <=> b[0]}
# pp targets

recs = Array.new(30){[0,0]}
targets.each{|t|
	i = 0
	while(i < 30)
		if(recs[i][0] < t[0] || recs[i][0] == t[0] && recs[i][1] == t[2])
			recs[i][0] = t[1]
			recs[i][1] = t[2]
			break
		end
		i += 1
	end
}
puts recs.count{|i| i[0] > 0}


Measured memory_bytes: 11384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k <= a) {
        cout << k << endl;
        return 0;
    }
    if (k <= a + b) {
        cout << a << endl;
        return 0;
    }
    k -= a + b;
    ll res = a - k;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>

int main(void)
{
  double r, s, l;

  scanf("%lf", &r);

  s = M_PI*r*r;
  l = 2.0*M_PI*r;

  printf("%.6lf %.6lf\n", s, l);

  return 0;
}

Measured memory_bytes: 1080
import math
# = int(input())
A, B, H, M = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
Arad = math.radians((H/12+M/720)*360)
Brad = math.radians((M/60)*360)

C = A**2 + B**2 - 2*B*A*math.cos(Brad-Arad)

print(C**(1/2))


Measured memory_bytes: 9496
#include <iostream>
#include <cmath>
#include <cstdio>
#include <string>

using namespace std; 

void bubblesort(int value[], char suit[], int n){
	for (int i=0; i<n; i++){
		for (int j=n-1; j>i; j--){
			if (value[j] < value[j-1]){
				int tmp_value = value[j];
				char tmp_suit = suit[j];
				value[j] = value[j-1];
				suit[j] = suit[j-1];
				value[j-1] = tmp_value;
				suit[j-1] = tmp_suit;
			}
		}
	}	
}

void selectionsort(int value[], char suit[], int n){
	for (int i=0; i<n; i++){
		int minj = i;
		for (int j=i; j<n; j++){
			if (value[j] < value[minj]){
				minj = j;
			}
		}
		if (minj != i){
			int tmp_value = value[i];
			char tmp_suit = suit[i];
			value[i] = value[minj];
			suit[i] = suit[minj];
			value[minj] = tmp_value;
			suit[minj] = tmp_suit;
		}
	}
}

void is_stable(int value[], char suit[], int v[], char s[], int n){
	char order[40];
	int ordercnt[10];
	char o[40];
	int ocnt[10];

	//initialize
	for (int i=0; i<10; i++){
		ordercnt[i] = 0;
		ocnt[i] = 0;
		for (int j=0; j<4; j++){
			//initialize
			order[j*10+i] = 'a';
			o[j*10+i] = 'a';
		}
	}

	for (int i=0; i<n; i++){
		order[ordercnt[value[i]]*10+value[i]] = suit[i];
		o[ocnt[v[i]]*10+v[i]] = s[i];
		ordercnt[value[i]] += 1;
		ocnt[v[i]] += 1;
	}

	bool stable = true;
	for (int i=0; i<40; i++){
		if (order[i] != o[i]){
			stable = false;
		}
	}

	if (stable){
		cout << "Stable" << endl;
	}
	else{
		cout << "Not stable" << endl;
	}
}

void copylist(int aint[], char achar[], int bint[], char bchar[], int n){
	for (int i=0; i<n; i++){
		bint[i] = aint[i];
		bchar[i] = achar[i];
	}
}

void printarray(int value[], char suit[], int n){
	for (int i=0; i<n; i++){
		if (i==n-1){
			cout << suit[i] << value[i] << endl;
		}
		else{
			cout << suit[i] << value[i] << " ";
		}
	}
}

int main(){
	int n;
	cin >> n;
	int value[n];
	char suit[n];
	for (int i=0; i<n; i++){
		int tmp_value;
		char tmp_suit;
		char tmp[2];
		cin >> tmp;
		value[i] = tmp[1]-'0';
		suit[i] = tmp[0];
	}
	int lb_value[n];
	char lb_suit[n];
	int ls_value[n];
	char ls_suit[n];
	copylist(value,suit,lb_value,lb_suit,n);
	copylist(value,suit,ls_value,ls_suit,n);

	bubblesort(lb_value, lb_suit, n);
	selectionsort(ls_value, ls_suit, n);

	printarray(lb_value, lb_suit, n);
	is_stable(value, suit, lb_value, lb_suit, n);
	printarray(ls_value, ls_suit, n);
	is_stable(value, suit, ls_value, ls_suit, n);

	return 0;
}













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

int main()
{
	int a,b,c,count=3;
	cin>>a>>b>>c;
	if (a == b){
		count--;
		if (b == c)
			count--;
		
	}else if (a == c){
		count--;
		if (b == c)
			count--;
	}else if (b == c){
		count--;
		if (a==c)
			count--;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
class BellmanFord{
    private:
    typedef std::pair<std::pair<int,int>,long long> P;
    int V,E;
    long long INF = (1LL<<61);
    std::vector<std::pair<std::pair<int,int>,long long>> es;
    
    public:
    void init(std::vector<std::pair<std::pair<int,int>,long long>> edge){
        //辺数をもとめる　
        E=edge.size();
        //頂点数を決定する
        V=0;
        for(int i=0;i<edge.size();i++){
            V=std::max(V,edge[i].first.first+1);
            V=std::max(V,edge[i].first.second+1);
        }
        es=edge;
    }
    
    std::vector<std::pair<long long,bool>> solve(int s){
        std::vector<std::pair<long long,bool>> d;
        //INFで初期化する
        for(int i=0;i<V;i++){
            d.push_back({INF,false});
        }
        d[s].first=0;
        for(int j=0;j<2*V;j++){
             bool update=false;
            for(int i=0;i<E;i++){
                P k=es[i];
                if(d[k.first.first].first!=INF && d[k.first.second].first>d[k.first.first].first+k.second){
                    d[k.first.second].first=d[k.first.first].first+k.second;
                    if(j>=V){
                        d[k.first.second].second=true;
                    }
                    update=true;
                }
            }
            if(!update)break;
        }
        return d;
    }
    
    //init:{{int,int},longlong}のvectorを渡すことで有向グラフを構築する
    //solve:始点を渡すとinitで構築したグラフでベルマンフォードをし、コストのvectorを返す
};

int main(){
    int N,M;
    int a[114514],b[114514],c[114514];
    std::vector<std::pair<std::pair<int,int>,long long>> G;
    std::vector<std::pair<long long,bool>> D;
    cin >> N >> M;
    REP(i,M){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;b[i]--;
        G.push_back({{a[i],b[i]},-c[i]});
    }
    BellmanFord bell;
    bell.init(G);
    D = bell.solve(0);
    if(D[N-1].second){
        cout << "inf" << endl;
    }else{
        cout << -D[N-1].first << endl;
    }
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;

namespace program {
  class Program {
    static void Main()
    {
      var n = ScanInt();
      var m = ScanInt();
      if(n+m==3)
      Out("3");
      if(n+m==4)
        Out("2");
      if(n+m==5)
        Out("1");
    }
    static public void Out(object s) { Console.Write($"{s} "); }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int k; cin>>k;
    if(k%2==0) cout<<k/2 * k/2<<endl;
    else cout<<k/2 *(k/2+1)<<endl;
}

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

using namespace std;
int N,a[10100];
int ans;
int main() {
    scanf("%d",&N);
    for(int i=1;i<=N;++i) scanf("%d",a+i);
    for(int i=2;i<=N;++i) {
        if(a[i]==a[i-1]) {
            int j;
            for(j=1;j==a[i-1]||j==a[i+1];++j);
            a[i]=j;
            ++ans;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
map<int,bool>dp[2][9000];
 
signed main(){
	string s;cin>>s;
	int x,y;scanf("%d%d",&x,&y);
	vector<int>v{0};
	for(char c:s){
		if(c=='F')v.back()++;
		else v.push_back(0);
	}
	vector<int>a[2]{};
	rep(i,v.size()){
		a[i%2].push_back(v[i]);
	}
	dp[0][0][0]=true;dp[1][0][0]=true;
	rep(i,2)rep(j,a[i].size()){
		for(auto p:dp[i][j]){
			if(i||j)dp[i][j+1][p.first-a[i][j]]=true;
			dp[i][j+1][p.first+a[i][j]]=true;
		}
	}
	if(dp[0][a[0].size()][x]==true&&dp[1][a[1].size()][y]==true){
		puts("Yes");
	}
	else puts("No");
}

Measured memory_bytes: 232960
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <utility>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
using int64 = long long;
#define ForInt(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define ForIntInit(i, begin, end) for (int i = (begin); i < (end); ++i)
#define ForItr(it, itBegin, itEnd) for (auto (it) = (itBegin); (it) != (itEnd); ++(it))


int main()
{
	int n;
	cin >> n;
	vector<int64> a(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	multiset<int64> b;
	for (int i = n - 1; i >= 0; --i)
	{
		int color = 0;
		auto it = b.upper_bound(a[i]);
		if (it != b.end())
		{
			b.erase(it);
		}
		b.insert(a[i]);
	}
	cout << b.size() << endl;

	return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int x = 1;
  for (int i = 0;i < N;i++) {
    if (x * 2 < x + K) x *= 2;
    else x += K;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
typedef long long ll;
//orz yht
using namespace std;
ll n,sum1,sum2;
vector<ll>tot;
int main(){
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>n;
    vector<pair<ll,ll> >v(n);
    for(ll i=0;i<n;i++){
    	cin>>v[i].first>>v[i].second;
    	tot.push_back(v[i].first);
    	tot.push_back(v[i].second);
	}
	for(auto x : v){
		sum1+=x.first;
		sum2+=x.second;
	}
	ll ans=min(sum1,sum2);
	ll sum=0;
	sort(tot.begin(),tot.end());
	for(ll i=0;i<n;i++)
	sum+=tot[i];
	for(ll i=0;i<n;i++){
		ll mx=max(v[i].first,v[i].second);
		ll mn=min(v[i].first,v[i].second);
		if(mn>tot[n-1] || mx<tot[n-1]){
			cout<<sum;
			return 0;
		}
		ll tmp=sum;
		tmp+=mx-tot[n-1]+max(0ll,mn-tot[n-2]);
		ans=min(ans,tmp);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3956
#include <iostream>

using namespace std;

int main(){
	int R[200000], n;
	int i, max, min;

	cin >> n;

	for (i = 0; i < n; i++){
		cin >> R[i];
	}
	
	max = R[n - 1] - R[0];
	
	min = R[0];

	for (int j = 1; j < n; j++){
		if (max <= R[j] - min){
			max = R[j] - min;
		}
		if (min >= R[j]){
			min = R[j];
		}
	}

	cout << max << endl;
}

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
  
  string s;
  
  cin >> s;
  
  int ans = 700;
  
  rep( i , 3 ) {
    
    if( s[i] == 'o' ) ans+=100;
    
  }
  
  cout << ans << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int x,a; cin >> x >> a;
  if(x<a) cout << 0 << endl;
  else cout << 10 << endl;

 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll A,V,B,W,T; cin>>A>>V>>B>>W>>T;
  ll dis=abs(B-A);
  ll v=V-W;
  if(v<=0){
    cout<<"NO"<<endl;
    return 0;
  }
  ll time=dis/v;
  if(dis%v>0) time++;
  if(time>T) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}


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

int main() {
  int N , K ;
  int P ; 
  int price = 0  ; 

  
  cin >> N >> K ;
  
    vector<int> A(N) ;
  
  for (int i = 0 ; i < N ; i++){
    cin >> P ; 
    A.at(i) = P ; 
    
  }
  sort(A.begin() , A.end()) ; 
  
  for ( int i = 0 ; i < K ; i++){
    price = price + A.at(i) ; 
  }
    
  cout << price << endl ; 
  
}


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

int main(int argc, char** argv) {
  int a[5]{};
  int k;
  bool ret = true;
  for (int i = 0; i < 5; ++i) cin >> a[i];
  cin >> k;
  for (int i = 0; i < 4; ++i) {
    for (int j = i + 1; j < 5; ++j) {
      if ((a[j] - a[i]) > k) { ret = false; }
    }
  }
  
  if (ret) 
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl; 

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1005,M=2005,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,m,ans,u[M],v[M],w[M],h[M],b[M],fat[N];
ll X,Y;
int depth[N],fa[N],f[N];
vector<pair<int,int> > e[N];
bool cmp(int x,int y){return w[x]<w[y];}
int find(int x){return (x==fat[x]) ? x : fat[x]=find(fat[x]);}
void merge(int x,int y){x=find(x);y=find(y);fat[y]=x;}
void work(int x,int fath){
	fa[x]=fath;depth[x]=depth[fath]+1;
	for (auto t : e[x])
	if (t.first!=fath){f[t.first]=t.second;work(t.first,x);}
}
int get(int x,int y){
	int t=0;
	while (x!=y){
		if (depth[x]<depth[y]) swap(x,y);
		t=max(t,f[x]);x=fa[x];
	}
	return t;
}
int main(){
	n=read();m=read();scanf("%lld",&X);
	for (int i=1;i<=m;i++){u[i]=read();v[i]=read();w[i]=read();b[i]=i;}
	sort(b+1,b+m+1,cmp);
	for (int i=1;i<=n;i++) fat[i]=i;
	for (int i=1;i<=m;i++){
		int x=b[i];
		if (find(u[x])!=find(v[x])){h[x]=1;merge(u[x],v[x]);Y+=w[x];}
	}
	if (Y>X) {puts("0");return 0;}
	else if (Y==X) ans=(ll)(qpow(2,n-1)-2+p)*qpow(2,m-n+1)%p;
	for (int i=1;i<=m;i++)
	if (h[i]){
		e[u[i]].push_back(make_pair(v[i],w[i]));
		e[v[i]].push_back(make_pair(u[i],w[i]));
	}
	work(1,0);
	int cnt=0;
	for (int i=1;i<=m;i++)
	if (!h[i]){
		b[++cnt]=i;
		w[i]-=get(u[i],v[i]);
	}
	sort(b+1,b+cnt+1,cmp);
	for (int i=1;i<=cnt;i++)
	if (w[b[i]]==X-Y) ans=(ans+qpow(2,m-n+2-i))%p;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stack>


using namespace std;

const int N = 1000;

int main()
{
	stack<int> S[N];
	int n, q;
	cin >> n >> q;
	
	while (q--)
	{
		int d, t;
		cin >> d >> t;
		if (d == 0)
		{
			int x;
			cin >> x;
			S[t].push(x);
		}
		else if (d == 1)
		{
			if (!S[t].empty())
				cout << S[t].top() << endl;
		}
		else
		{
			if (!S[t].empty())
				S[t].pop();
		}
	}
}


Measured memory_bytes: 4328
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 

const long long mod=1e9+7;

int main(){

    string l;
    cin>>l;

    int n=l.size();

    vector<long long> p2(n+1),p3(n+1);
    p2[0]=p3[0]=1;
    for(int i=1;i<=n;i++){
        p2[i]=(p2[i-1]*2LL)%mod;
        p3[i]=(p3[i-1]*3LL)%mod;
    }

    long long res=0;
    int b=0;
    for(int i=0;i<n;i++){
        if(l[i]=='0') continue;

        res=(res+(p2[b]*p3[n-i-1])%mod)%mod;
        b++;
    }
    cout<<(res+p2[b])%mod<<endl;

    return 0;
}

Measured memory_bytes: 2048
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n,k; cin>>n>>k;
	map<int,int> mp;
	vector<int> v(n+1);
	v[0]=0;
	For(i,1,n){
		cin>>v[i];
		v[i]=(v[i]%k-1+v[i-1]+k)%k;
		//cerr<<v[i]<<" \n"[i==n];
	}
	int ans=0;
	For(i,0,n){
		ans+=mp[v[i]];
		//cerr<<i<<" "<<mp[(k-v[i])%k]<<"\n";
		mp[v[i]]++;
		if(i>=k-1) mp[v[i-k+1]]--;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, i, j, a[1010][1010], t = -1, k[1010] = {};
    bool d[1010], pos = true;
    cin >> n;
    for (i = 1; i <= n; i++)
        for (j = 0; j < n - 1; j++) cin >> a[i][j];
    while (pos) {
        t++;
        pos = false;
        for (i = 1; i <= n; i++) d[i] = false;
        for (i = 1; i <= n; i++)
            if (k[i] != n - 1) {
                j = a[i][k[i]];
                if (!d[i] && !d[j] && a[j][k[j]] == i) {
                    pos = true;
                    k[i]++;
                    k[j]++;
                    d[i] = true;
                    d[j] = true;
                }
            }
    }
    for (i = 1; i <= n; i++)
        if (k[i] != n - 1) break;
    if (i == n + 1)
        cout << t << endl;
    else
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 4224
#include<stdio.h>

int solve(int, int, int *, int);

int main(){
  int i, n, A[2000], q, mi[2000];

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&mi[i]);
  }

  for(i = 0; i < q; i++){
    if(solve(0,mi[i],A,n) == 1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}
 
int solve(int i, int m, int *A, int n){
  int res;
  if(m == 0) return 1;
  if(i >= n) return 0;
  if(solve(i + 1, m, A, n) == 1|| solve(i + 1, m-A[i], A, n) == 1) res = 1;
  else res =0;
  return res;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main{
    private static Scanner sc=new Scanner(System.in);
    private static long n=sc.nextLong();
    public static void main(String[] args){
        int sq=(int)(Math.sqrt(n));
        int ans=0;
        for(int i=sq;i>=1;i--){
            if(n%i==0){
                ans=String.valueOf(n/i).length();
                i=0;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    long long sum = abs(a.at(0))+abs(a.at(n-1));
    rep(i, n-1){
        sum += abs(a.at(i)-a.at(i+1));
    }
    int tmp = 0;
    rep(i, n){
        if(i==0)
        tmp = abs(a.at(0))+abs(a.at(0)-a.at(1))-abs(a.at(1));
        else if(i == n-1)
        tmp = abs(a.at(n-1))+abs(a.at(n-1)-a.at(n-2))-abs(a.at(n-2));
        else
        tmp = abs(a.at(i)-a.at(i-1))+abs(a.at(i)-a.at(i+1))-abs(a.at(i+1)-a.at(i-1));
        
        cout << sum-tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int hasNext;
		while ((hasNext = in.nextInt()) != 0) {
			while (hasNext-- > 0) {
				int pm = in.nextInt();
				int pe = in.nextInt();
				int pj = in.nextInt();
				int all;
				if (pm == 100 || pe == 100 || pj == 100
						|| (all = pm + pe + pj) >= 240 || (pm + pe) >= 180) {
					System.out.println('A');
					continue;
				} else if (all >= 210 || (all >= 150 && (pm >= 80 || pe >= 80))) {
					System.out.println('B');
					continue;
				} else {
					System.out.println('C');
				}
			}
		}
	}
}

Measured memory_bytes: 28320
import java.util.Scanner;
 
public final class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    
    int a = stdIn.nextInt();
    int b = stdIn.nextInt();
    int c = stdIn.nextInt();
    
    if(c-(a-b)>=0){
      System.out.println(c-(a-b));
    }else{
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 23124
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s,ans;
	while(1){
		getline(cin,s);
		if(s=="END OF INPUT")break;
		ans="";
		int cnt=0;
		rep(i,s.size()+1){
			if(s[i]==' ' || s[i]=='\0'){
				ans+=(char)(i-cnt+'0');
				cnt=i+1;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

bool OK[2005][2005];
int Yoko[2005][2005];
int Tate[2005][2005];
int main(void) {
   ll H,W;
   cin>>H>>W;
   rep(i,2005) {
      rep(j,2005) {
         OK[i][j] = false;
         Yoko[i][j] = 0;
         Tate[i][j] = 0;
      }
   }
   rep(i,H) {
      string S;
      cin>>S;
      rep(j,W) {
         if (S[j] != '#') OK[i+1][j+1] = true; 
      }
   }
   rep(i,2005) {
      int now = 0;
      rep(j,2005) {
         if (!OK[i][j]) {
            for (int k = j-now; k < j;k++) Yoko[i][k] = now;
            now = 0;
            Yoko[i][j] = 0;
         } else now++;
      }
   }

   rep(j,2005) {
      int now = 0;
      rep(i,2005) {
         if (!OK[i][j]) {
            for (int k = i-now; k < i;k++) Tate[k][j] = now;
            now = 0;
            Tate[i][j] = 0;
         } else now++;
      }
   }
   int ans = 1;
   rep(i,2005) {
      rep(j,2005) {
         // cout<<Yoko[i][j] + Tate[i][j]<<endl;
         ans = max(ans,Yoko[i][j] + Tate[i][j]-1);
         // cout<<Tate[i][j]<<endl;
      }
   }
   cout<<ans<<endl;






   return 0;
}

Measured memory_bytes: 35584
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll a,b;
    std::cin >> a>>b;
    ll result = 0;
    // 各桁の数をかぞえよう
    for (int i = 0; i < 41; i++) {
        ll count_a = 0;
        ll count_b = 0;
        if(a==0){
            count_a = 0;
        }else{
            count_a = ( (a-1)/(ll)pow(2,i+1) )* (ll)pow(2,i) + max((ll)0, (a-1)%(ll)pow(2,i+1) - (ll)pow(2,i)+1);
        }
        count_b = ( b/(ll)pow(2,i+1) )* (ll)pow(2,i) + max((ll)0, b%(ll)pow(2,i+1) - (ll)pow(2,i) +1);
        // std::cout << count_b<<" "<<count_a << std::endl;
        
        if( (count_b - count_a)%2 !=0 ){
            result += (ll)pow(2,i);
        }
    }
    
    std::cout << result << std::endl;
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll a[N];
int main()
{
	int n;
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i ++)
	{
		cin >> a[i];
		ll q = a[i] & -a[i];
		q = log2(q);
		sum += q;
	}
	cout << sum;



	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 384
//******************************************************************************
// File Name: F.cpp
// Author: Shili_Xu
// E-Mail: shili_xu@qq.com
// Created Time: 2018年09月04日 星期二 22时20分45秒
//******************************************************************************

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;

int t;
ll a, b, c, d;

ll gcd(ll a, ll b)
{
	return (!b ? a : gcd(b, a % b));
}

int main()
{
	scanf("%d", &t);
	while (t--) {
		scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
		bool ans = true;
		if (a < b)
			ans = false;
		else {
			if (d < b)
				ans = false;
			else {
				if (c < b) {
					ll g = gcd(b, d);
					ll mn = (a - b) / g, mx = (a - c - 1) / g;
					if (mx - mn > 0) ans = false;
				}
			}
		}
		printf("%s\n", ans ? "Yes" : "No");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  ll ans1 = 1, ans2 = 1, ans3 = 1;
  rep(i, 0, n) {
    ans1 *= 10;
    ans2 *= 9;
    ans3 *= 8;
    ans1 %= 1000000007;
    ans2 %= 1000000007;
    ans3 %= 1000000007;
  }
  ans2 = ans2 * 2 % 1000000007;
  ll ans = 0;
  ans = (ans1 - ans2 + ans3)%1000000007;
  ans=(ans+1000000007)%1000000007;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628