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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    double T,X;
    cin >> T >> X;

    put_double(T/X);

}


Measured memory_bytes: 256
def main():
	n = [int(i) for i in input()]
	for i in range(7):
		x2 = base_10_to_n(i,2)
		for _ in range(3-len(x2)):	
			x2 = '0' + x2
		ans = n[0]
		for j in range(3):
			if(x2[j] == '0'):
				ans += n[j+1]
			else:
				ans -= n[j+1]
		if(ans == 7):
			text = str(n[0])
			for j in range(3):
				if(x2[j] == '0'):
					text = text + '+' + str(n[j+1])
				else:
					text = text + '-' + str(n[j+1])
			print(text+'=7')
			return 0

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

Measured memory_bytes: 38384
import java.util.*;

class Main {

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

		int N=sc.nextInt();

		long A[]=new long[N];

		for(int i=0;i<N;i++) {

			A[i]=sc.nextLong();

		}sc.close();

		Arrays.parallelSort(A);

		long res=0;

		Deque<Long> deque = new ArrayDeque<>();

		for(int i=N-1;i>=0;i--) {

			deque.add(A[i]);

			if(i!=N-1) {

				deque.add(A[i]);//if(A[i]!=deque.peek()) {

					//System.out.println(deque.peek());

					res+=deque.poll();

				/*}else {

					res+=A[i];

					System.out.println(A[i]);

				}*/

			}

		}

		System.out.println(res);

	}

}

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;





int main() {
	int n;
	cin >> n;
	int res = 0;
	if (n < 299999999) {
		REP(i, n + 1) {
			int j = i;
			bool a = false, b = false, c = false;
			bool d = true;
			while (j) {
				int k = j % 10;
				j /= 10;
				if (k == 3)a = true;
				else if (k == 5)b = true;
				else if (k == 7)c = true;
				else {
					d = false;
					break;
				}
			}
			if (a&&b&&c&&d) {
				res++;
			}
		}
		cout << res << endl;
	}
	else if(n< 399999999) {
		FOR(i, 299999999, n + 1) {
			int j = i;
			bool a = false, b = false, c = false;
			bool d = true;
			while (j) {
				int k = j % 10;
				j /= 10;
				if (k == 3)a = true;
				else if (k == 5)b = true;
				else if (k == 7)c = true;
				else {
					d = false;
					break;
				}
			}
			if (a&&b&&c&&d) {
				res++;
			}
		}
		cout << res+8334 << endl;
	}
	else if (n < 599999999) {
		FOR(i, 299999999, 379999999) {
			int j = i;
			bool a = false, b = false, c = false;
			bool d = true;
			while (j) {
				int k = j % 10;
				j /= 10;
				if (k == 3)a = true;
				else if (k == 5)b = true;
				else if (k == 7)c = true;
				else {
					d = false;
					break;
				}
			}
			if (a&&b&&c&&d) {
				res++;
			}
		}
		FOR(i, 499999999, n + 1) {
			int j = i;
			bool a = false, b = false, c = false;
			bool d = true;
			while (j) {
				int k = j % 10;
				j /= 10;
				if (k == 3)a = true;
				else if (k == 5)b = true;
				else if (k == 7)c = true;
				else {
					d = false;
					break;
				}
			}
			if (a&&b&&c&&d) {
				res++;
			}
		}
		cout << res+8334 << endl;

	}
	else {
		FOR(i, 299999999, 379999999) {
			int j = i;
			bool a = false, b = false, c = false;
			bool d = true;
			while (j) {
				int k = j % 10;
				j /= 10;
				if (k == 3)a = true;
				else if (k == 5)b = true;
				else if (k == 7)c = true;
				else {
					d = false;
					break;
				}
			}
			if (a&&b&&c&&d) {
				res++;
			}
		}
		FOR(i, 499999999, 579999999) {
			int j = i;
			bool a = false, b = false, c = false;
			bool d = true;
			while (j) {
				int k = j % 10;
				j /= 10;
				if (k == 3)a = true;
				else if (k == 5)b = true;
				else if (k == 7)c = true;
				else {
					d = false;
					break;
				}
			}
			if (a&&b&&c&&d) {
				res++;
			}
		}
		FOR(i, 699999999, n+1) {
			int j = i;
			bool a = false, b = false, c = false;
			bool d = true;
			while (j) {
				int k = j % 10;
				j /= 10;
				if (k == 3)a = true;
				else if (k == 5)b = true;
				else if (k == 7)c = true;
				else {
					d = false;
					break;
				}
			}
			if (a&&b&&c&&d) {
				res++;
			}
		}
		cout << res+8334 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
///ALLAH HU AKBAR
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    string S;
    cin>>N>>S;
    if(N%2!=0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        string T=S.substr(0,N/2);
        if(T+T==S)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;

    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char S[111];
int main(){
    cin>>S + 1;
    int n = strlen(S + 1);
    int flag = 1;
    for(int i = 1;i <= n; i += 2){
        if(S[i] == 'L')flag = 0;
    }
    for(int i = 2;i <= n; i += 2){
        if(S[i] == 'R')flag = 0;
    }
    if(flag)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
int main(){
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    while(k--){
        if(b<=a) {
            b*=2;
            continue;
        }
        if(c<=b){
            c*=2;
            continue;
        }
    }
    if(a<b&&b<c) puts("Yes");
    else puts("No");
}


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

// 無向グラフ
using Graph = vector<vector<int>>;

void DFS(Graph &g, vector<bool> &seen, int p, int &counter)
{
    seen[p] = true;
    for (auto &&gi : g[p])
    {
        if (seen[gi]) continue;
        counter++;
        DFS(g, seen, gi, counter);
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    Graph g(n);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    vector<bool> seen(n, false);
    vector<int> csizes;
    for (int v = 0; v < n; v++)
    {
        if (seen[v]) continue;
        int nowsize = 1;
        DFS(g, seen, v, nowsize);
        csizes.push_back(nowsize);
    }

    // printvec(csizes);

    int maxsize = 0;
    for (auto &&csize : csizes)
    {
        maxsize = max(csize, maxsize);
    }
    
    int ans = maxsize;
    cout << ans << endl;

    return 0;
}

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

def bingo_check(card):
    #横チェック
    for low in card:
        if sum(low)==0:
            print("Yes")
            exit()
    #縦チェック
    column1=0
    column2=0
    column3=0
    for low in card:
        column1+=low[0]
        column2+=low[1]
        column3+=low[2]
    if column1 == 0 or column2 == 0 or column3==0:
        print("Yes")
        exit()
    #斜めチェック
    diagonal1=card[0][0]+card[1][1]+card[2][2]
    diagonal2=card[0][2]+card[1][1]+card[2][0]
    if diagonal1 == 0 or diagonal2 == 0:
        print("Yes")
        exit()
    print("No")

def main():
    bingo=[]
    use_card=[]
    bingo=[list(map(int,input().split())) for _ in range(3)]
    use_card=bingo
    n = int(input())

    for idx in range(n):
        number=int(input())
        for i in range(3):
            for j in range(3):
                if number==use_card[i][j]:
                    use_card[i][j]=0
                else:
                    continue
    bingo_check(use_card)

if __name__=="__main__":
    main()

Measured memory_bytes: 9284
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=0; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;

int main()
{
  int n, m ;
  cin >> n >> m ;
  vector<vector<int>> vec(n,vector<int>(m,0)) ;
  vector<int> count(m) ;
  int sum = 0 ;
  
  REP(i,n){
    int k ;
    cin >> k ;
    REP(j,k){
      cin >> vec.at(i).at(j) ;
    }
  }
  
  REP(l,m){
    REP(i,n){
      REP(j,m){
        if(vec.at(i).at(j)==l+1){
          count.at(l)++ ;
        }
      }
    }
    if(count.at(l)==n){
      sum++ ;
    }
  }
  
  cout << sum <<endl ;
  
  return 0 ;
}




Measured memory_bytes: 256
n = gets.to_i
a_n = gets.split.map(&:to_i).sort!
max = a_n.max
memo = Array.new(max + 1, 1)

ans = Hash.new(0)
n.times do |i|
    if ans.has_key?(a_n[i])
        ans[a_n[i]] = 0
    end

    next if memo[a_n[i]] == 0

    ans[a_n[i]] += 1
    x = a_n[i]
    x.step(max, x) do |st|
        memo[st] = 0
    end
end

puts ans.count {|k, v| v == 1}


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

int main() {
	int n,i,j,min=1000000,max=-1000000;
	long sum=0;
	
	for(cin>>n,j=0;j<n;++j){
		cin>>i;
		
		if(i<min)min=i;
		if(i>max)max=i;
		sum+=i;
	}
	
	cout<<min<<" "<<max<<" "<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <set>
#include <climits>

#define N 4
#define N2 16

using namespace std;

// const int N = 4;
// const int N2 = 16;

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'}; 


struct Node
{
	int puzzle[N2];
	int space;
	int md;
};

class Npuzzle
{
private:
	Node s_node;
	int limit;
	int md[N2][N2];
	vector<int> path;
	int ans;
public:
	Npuzzle() {
		s_node = Node();
		int in[N2];
		for (int i = 0; i < N2; ++i)
		{
			int tmp;
			cin >> tmp;
			if(tmp == 0) {
				tmp = N2;
				s_node.space = i;
			}
			s_node.puzzle[i] = tmp;
		}
		set_md();
		s_node.md = get_md_sum(s_node.puzzle);
	}

	int get_md_sum(int *puzzle) {
		int sum = 0;
		for (int i = 0; i < N2; ++i)
		{
			if(puzzle[i] == N2) continue;
			sum += md[i][puzzle[i]-1];
		}
		return sum;
	}

	void set_md() {
		for (int i = 0; i < N2; ++i)
		{
			for (int j = 0; j < N2; ++j)
			{
				md[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
			}
		}
	}

	bool dfs(Node cur_n, int depth, int pre) {
		if(cur_n.md == 0 ) {
			ans = depth;
			return true;
		}
		if(depth + cur_n.md > limit) return false;
		int s_x = cur_n.space / N;
		int s_y = cur_n.space % N;
		for (int i = 0; i < 4; ++i)
		{
			Node new_n = cur_n;
			int new_x = s_x + dx[i];
			int new_y = s_y + dy[i];
			if(new_x < 0  || new_y < 0 || new_x >= N || new_y >= N) continue; 
			if(max(pre, i) - min(pre, i) == 2) continue;

			new_n.md -= md[new_x * N + new_y][new_n.puzzle[new_x * N + new_y] - 1];
			new_n.md += md[s_x * N + s_y][new_n.puzzle[new_x * N + new_y] - 1];
			swap(new_n.puzzle[new_x * N + new_y], new_n.puzzle[s_x * N + s_y]);
			new_n.space = new_x * N + new_y;
			// assert(get_md_sum(new_n.puzzle) == new_n.md);
			// return dfs(new_n, depth+1, i);
			if(dfs(new_n, depth + 1, i)){
				path[depth] = i;
				return true;
			}
		}
		return false;
	}

	void ida_star() {
		for (limit = s_node.md; limit < 1000; ++limit)
		{
			path.resize(limit);
			if(dfs(s_node, 0, -10)) {
				cout << limit << endl;
				// string str = "";
				// for (int i = 0; i < limit; ++i)
				// {
				// 	str += dir[path[i]];
				// }
				// cout << str << endl;
				return;
			}
		}
	}

	void exec() {
		ida_star();
	}
};


int main() {
	Npuzzle np = Npuzzle();
	np.exec(); 
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    for (int _ = 1; _ < n; _++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    vector<int> a(n);
    vector<bool> trk(n);
    priority_queue<pair<int,int>> pq;
    int k; cin >> k;
    for (int _ = 0; _ < k; _++) {
        int i, x;
        cin >> i >> x;
        i--;
        trk[i] = true;
        a[i] = x;
        pq.emplace(x, i);
    }
    while (!pq.empty()) {
        int x,i;
        tie(x,i) = pq.top(); pq.pop();
        for (int v: g[i]) {
            if (trk[v]) {
                if (abs(a[v]-x) != 1) {
                    cout << "No"; return;
                }
            } else {
                a[v] = x - 1;
                trk[v] = true;
                pq.emplace(a[v], v);
            }
        }
    }
    cout << "Yes\n";
    for (auto& x: a) {
        cout << x << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 7924
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    tmp0 = input[0].split(" ");
   // tmp1 = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
    var r = parseInt(tmp0[0], 10);
    if(r<1200){console.log('ABC')}
     else if(r<2800){console.log('ARC');}
      else{console.log('AGC');}
    
                    }

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[100]={};
	int b,c,d,e,ans=0;
	cin>>b>>c>>d>>e;
	for(int i=b;i<c;i++){
		a[i]++;
	}
	for(int i=d;i<e;i++){
		a[i]++;
	}
	for(int i=0;i<100;i++){
		if(a[i]==2){
			ans++;
		}
	}
	cout<<ans<<endl;
}


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

int main(){
  string w;
  cin>>w;
  vector<int> c(26);
  for(char x : w) ++c[(int)x-97];
  for(int i=0;i<26;++i){
    if(c[i]%2!=0){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include<map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef unsigned int ui;
typedef unsigned short us;
typedef unsigned long long ull;

using namespace std;


int inputValue() {
  int a;
  scanf("%d", &a);
  return a;
};
void inputVector(vector<int>* v) {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  p->clear();
  p->shrink_to_fit();
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, ui r, ui c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}

template<template <class...> class Map, typename T_0, typename T_1, typename... Args>
void inputMap(Map<T_0, T_1, Args...>& mp) {
  T_0 a;
  T_1 b;
  while (cin >> a && a != -1) {
    cin >> b;
    mp.insert(make_pair(a, b));
  }
}

template<template <class...> class Vec, typename T, typename U, typename... Args>
void numberToBoolenVector(Vec<T, Args...>& vec, U a) {
  ui i = 0;
  T amari;
  do {
    if (a % (ull)pow(2, i + 1)) {
      amari = 1;
      vec.push_back(amari);
      a -= (ull)pow(2, i);
    }
    else {
      amari = 0;
      vec.push_back(amari);
    }
    i++;
  } while (a);
}

template<template <class...> class Vec, typename T, typename... Args>
ull boolenVectorToNumber(Vec<T, Args...>& vec) {
  ull r = 0;
  for (size_t i = 0; i < vec.size(); i++)
  {
    r += vec[i] * (ull)pow(2, i);
  }
  return r;
}

int main(int argc, const char * argv[]) {
  ui a;
  ui b;
  ui k;
  vector<int> wareru;

  scanf("%d %d %d", &a, &b, &k);

  for (size_t i = 100; i > 0; i--)
  {
    if (a%i == 0 && b%i == 0) {
      wareru.push_back(i);
    }
  }


  printf("%d", wareru[k-1]);
  return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
s = int(input())

def f(b, n):
    ans = 0
    while b <= n:
        ans += n%b
        n //= b
    ans += n
    return ans

if n == s:
    print(n+1)
elif n < s:
    print(-1)
else:
    limit = math.ceil(math.sqrt(n))
    for b in range(2, limit + 1):
        if f(b, n) == s:
            print(b)
            break
    else:
        for p in range(limit, 0 ,-1):
            if s - p >= 0 and n-s+p > 0 and (n-s+p)//p > limit:
                b = (n-s+p)//p
                if f(b, n) == s:
                    print(b)
                    break
        else:
            print(-1)

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <queue>
#include <iostream>
#include <string>
using namespace std;



int main()
{
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	if (a1 + a2 + a3 >= 22) cout << "bust";
	else
		cout << "win";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n,t;
  cin >> n >> t;
  int a[n];
  int ans = 0;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  for (int i = 0; i < n-1; i++) {
    int diff = a[i+1] - a[i];
    if(diff > t){
        ans += t;
    }else{
        ans += diff;
    }
  }
  ans += t;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split())) 
size = [0] * N
ans = 0
for i in range(N):
    size[A[i]-1] += 1

for i in range(N):
    if(size[i] >= 2):
        ans += int(size[i] * (size[i]-1) / 2)

for k in range(N):
    if(size[A[k]-1] <= 1):
        print(ans)
    else:
        print(ans - (size[A[k]-1]-1))

Measured memory_bytes: 26524
/*
C:\Users\jolog\CLionProjects\progcpp
 */
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define int long long

signed main() { //[J][O][L][S][K][E][Y]
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int n, m; cin >> n >> m;
        vector<int> vec(n);
        for (int i = 0; i < n;i ++) cin >> vec[i];
        double k = accumulate(all(vec), 0ll);
        k /= 4 * m;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
                if (vec[i] >= k) cnt++;
        }

        cout << (cnt >= m ? "Yes" : "No");
        return 0;
}

/*

*/

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

using namespace std;

const int size = 5e5+10;
const int INF = 1e9;

int d[size][3];
int a[size][2];

int main() {
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int c1 = 0;
	int c0 = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '0') {
			a[c0][0] = c1;
			if (c0 > 0)
				a[c0-1][1] = c1;
			c1 = 0;
			c0++;
		}
		else
			c1++;
	}
	a[c0-1][1] = c1;
	if (a[0][0] == 0 || a[0][1] == 0) {
		d[0][0] = 0;
		d[0][1] = 0;
	}
	else {
	d[0][0] = a[0][0];
	d[0][1] = a[0][1];
	}	
	d[0][2] = 0;
	for (int i = 1; i < c0; i++) {
		//cout << "(" << a[i][0] << ' ' << a[i][1] << "), ";
		if (a[i][0] == 1 && a[i][1] != 0) {
			d[i][0] = d[i-1][2] + a[i][0];
			d[i][1] = d[i-1][2] + a[i][1];
		}
		else if (a[i][0] != 0 && a[i][1] != 0) {
				d[i][0] = max(d[i-1][0] - 1, d[i - 1][2]) + a[i][0];
				d[i][1] = max(max(d[i-1][0], d[i-1][1] - 1), d[i-1][2]) + a[i][1];
		}
		d[i][2] = max(max(d[i-1][0], d[i-1][1]), d[i-1][2]);
		//cout << d[i][2] << ' ';
	}
	if (c0 > 0)
		cout << max(max(d[c0-1][0], d[c0-1][1]), d[c0-1][2]) << '\n';
	else
		cout << 0 << '\n';
	return 0;
}

Measured memory_bytes: 10616
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int x = 0;
    int res = 0;
    rep(i, S.size()) {
        if(S[i] == 'I') {
            x++;
            res = max(res, x);
        } else {
            x--;
            res = max(res, x);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll r,c;cin>>r>>c;
    vvl a(r+1,vl(c+1));
    rep(i,r)rep(j,c)cin>>a[i][j];

    rep(i,r){
        ll sum=0;
        rep(j,c)sum+=a[i][j];
        a[i][c]=sum;
    }
    rep(i,c+1){
        ll sum=0;
        rep(j,r)sum+=a[j][i];
        a[r][i]=sum;
    }

    rep(i,r+1){
        rep(j,c+1){
            if(j>0)cout<<" ";
            cout<<a[i][j];
        }
        cout<<endl;
    }
}

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



Measured memory_bytes: 3208
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int H; int W; int d;
	while (~scanf("%d%d%d", &H, &W, &d)) {
		const char *colors = "RYGB";
		vector<string> ans(H, string(W, '?'));
		rep(i, H) rep(j, W)
			ans[i][j] = colors[(i + j) / d % 2 * 2 + (i + (W - 1 - j)) / d % 2];
		rep(i, H)
			puts(ans[i].c_str());
	}
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MP make_pair
#define endl '\n'
const int mod = 1e9 + 7;
const int MAXN = 3e5 + 5;
const int INF = 0x3f3f3f3f;

int isprime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0) return 0;
    }
    return 1;
}

int main(int argc, char* argv[]) {
#ifdef local
    // freopen("in.txt", "r", stdin);
#endif
    int x;
    cin >> x;
    for (int i = x; i <= 1e6; i++) {
        if (isprime(i)) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = 1000000000;

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

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
llint C(llint n, llint r, llint m) {
	llint ans = 1;
	for (llint i = 0; i < r; i++) {
		ans *= n - i;
		ans %= m;
	}
	for (llint i = 1; i <= r; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}


int main() {
	string s;
	cin >> s;
	cout << s;
	if (s[s.size() - 1] == 's')cout << "es" << endl;
	else cout << "s" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
// using Graph = vector<vector<int>>;
const int MOD = 1000000007;
const int maxn = 2e5 + 6;
vector<int> e[30];

int main() {
  string s, t;
  cin >> s >> t;
  int len = s.length();
  int len2 = t.length();
  for (int i = 0; i < len; i++) {
    e[s[i] - 'a'].push_back(i);
  }
  ll now = 0;
  ll cnt = 0;
  int flag = 1;
  for (int i = 0; i < len2; i++) {
    int u = t[i] - 'a';
    if (e[u].size() == 0) {
      flag = 0;
      break;
    }
    if (flag == 0) break;
    int pos = lower_bound(e[u].begin(), e[u].end(), now) - e[u].begin();
    if (pos >= e[u].size()) {
      now = 0;
      cnt++;
      pos = lower_bound(e[u].begin(), e[u].end(), now) - e[u].begin();
    }
    now = e[u][pos] + 1;
  }
  ll ans = 1ll * cnt * len + now;
  if (ans < 0)
    while (1)
      ;
  if (flag)
    cout << ans << endl;
  else
    cout << -1 << endl;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#define fr first
#define sc second
#define MP make_pair
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lli long long int
#define y1 arayikhalatyan
using namespace std;

lli gcd(lli a, lli b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
lli cg(lli n) {
	return n ^ (n >> 1);
}
lli SUM(lli a)
{
	return (a * (a + 1) / 2);
}
bool CAN(int x, int y, int n, int m)
{
	if (x >= 0 && y >= 0 && x < n && y < m)
	{
		return true;
	}
	return false;
}
double her(double x1, double y1, double x2, double y2)
{
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
string strsum(string a, string b)
{
	int p = 0;
	string c;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	if (b.length() < a.length())
	{
		for (int i = b.length(); i < a.length(); i++)
		{
			b += "0";
		}
	}
	else
	{
		for (int i = a.length(); i < b.length(); i++)
		{
			a += "0";
		}
	}

	a += "0", b += "0";
	for (int i = 0; i < a.length(); i++)
	{
		c += (a[i] - '0' + b[i] - '0' + p) % 10 + '0';
		p = (a[i] + b[i] - '0' - '0' + p) / 10;
	}
	if (c[c.length() - 1] == '0') c.erase(c.length() - 1, 1);
	reverse(c.begin(), c.end());
	return c;
}
string strmin(string a, string b)
{
	if (a.length() > b.length()) return b;
	if (b.length() > a.length()) return a;
	for (int i = 0; i < a.length(); i++)
	{
		if (a[i] > b[i]) return b;
		if (b[i] > a[i]) return a;
	}
	return a;
}

char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };



const int N = 1e6 + 30;
const lli mod = 1000000007;

int n;
double a[N];
int main()
{
	fastio;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++)
	{
		a[i + 1] = (a[i] + a[i + 1]) / 2;
	}
	cout << a[n - 1];
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,length;
    string a,b;
    char t;
    cin>>a>>b;
    length=a.length();
    for(i=0;i<length;i++){
        if(a!=b){
            t=a[length-1];
            a=a.erase(length-1);
            a=t+a;
        }
        else break;
    }
    if(i!=length) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        
        int test1,test2,test3;  //中間試験点数、期末試験点数、再試験点数
        int sum;    //中間試験、期末試験合計点数
        
        while(true){
            test1 = sc.nextInt();
            test2 = sc.nextInt();
            test3 = sc.nextInt();

            //終了条件
            if(test1 == -1 && test2 == -1 && test3 == -1)   break;

            //どちらか欠席の場合
            if(test1 == -1 || test2 == -1)  System.out.println("F");
            else{
                sum = test1 + test2;
                if(sum >= 80)   System.out.println("A");
                else if(sum >= 65)  System.out.println("B");
                else if(sum >= 50)  System.out.println("C");
                else if(sum >= 30){
                    if(test3 >= 50) System.out.println("C");
                    else    System.out.println("D");
                }
                else    System.out.println("F");
            }
        }
    }
}



Measured memory_bytes: 26184
class SegmentTree:
    def __init__(self, array, seg_func, ide_ele):
        n = len(array)
        self.size = 2**(n - 1).bit_length()
        self.seg_func = seg_func
        self.ide_ele = ide_ele
        self.seg = [self.ide_ele] * (2 * self.size - 1)

        for i in range(n):
            self.seg[i + self.size - 1] = array[i]
        for i in range(self.size - 2, -1, -1):
            self.seg[i] = self.seg_func(self.seg[2 * i + 1], self.seg[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        self.seg[index] = value
        while index:
            index = (index - 1) // 2
            self.seg[index] = self.seg_func(self.seg[index * 2 + 1], self.seg[index * 2 + 2])

    def query(self, lower_ep, upper_ep):
        if upper_ep <= lower_ep:
            return self.ide_ele
        lower_ep += self.size - 1
        upper_ep += self.size - 2
        res = self.ide_ele
        while (upper_ep - lower_ep) > 1:
            if lower_ep & 1 == 0:
                res = self.seg_func(res, self.seg[lower_ep])
            if upper_ep & 1 == 1:
                res = self.seg_func(res, self.seg[upper_ep])
                upper_ep -= 1

            lower_ep //= 2
            upper_ep = (upper_ep - 1) // 2
        if lower_ep == upper_ep:
            res = self.seg_func(res, self.seg[lower_ep])
        else:
            res = self.seg_func(self.seg_func(res, self.seg[lower_ep]), self.seg[upper_ep])
        return res


n, q = map(int, input().split())
seg = SegmentTree([2**31 - 1] * n, min, 2**31 - 1)
for _ in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        seg.update(x, y)
    if com == 1:
        print(seg.query(x, y + 1))



Measured memory_bytes: 8696
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cstring>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P; 
const int N = 1000006;
//////////////////////////////

Int fact[N], invfact[N], inv[N];
void init()
{
	fact[0] = 1;
	for (int i = 1; i < N; i++) {
		fact[i] = fact[i - 1] * i % MOD;
	}
	inv[1] = 1;
	for (int i = 2; i < N; i++) {
		inv[i] = -inv[MOD%i] * (MOD / i) % MOD;
		if (inv[i] < 0) inv[i] += MOD;
	}
	invfact[0] = 1;
	for (int i = 1; i < N; i++) {
		invfact[i] = invfact[i - 1] * inv[i] % MOD;
	}
}

Int nCk(Int n, Int k)
{
	return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}

Int dp[3300][2];
Int h, w, n, x, y;
vector<P> wall;

Int route(P a, P b)
{
	int x = b.first - a.first;
	int y = b.second - a.second;
	if (x < 0 || y < 0) return 0;
	return nCk(x + y, x);
}

int main()
{
	init();
	cin >> h >> w >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		wall.push_back(P(x, y));
	}
	wall.push_back(P(1, 1));
	sort(wall.begin(), wall.end());

	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < i; j++) {
			dp[i][0] += dp[j][1] * route(wall[j], wall[i]) % MOD;
			dp[i][0] %= MOD;
			dp[i][1] += dp[j][0] * route(wall[j], wall[i]) % MOD;
			dp[i][1] %= MOD;
		}
	}

	P goal = P(h, w);
	Int ban = 0;
	for (int i = 1; i <= n; i++) {
		ban -= dp[i][0] * route(wall[i], goal) % MOD;
		ban += dp[i][1] * route(wall[i], goal) % MOD;
		ban %= MOD;
	}

	Int ans = (nCk(h + w - 2, h - 1) - ban) % MOD;
	if (ans < 0) ans += MOD;

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


Measured memory_bytes: 23808
N=int(input())

for h in range(1, 3501):
    for w in range(1, 3501):
        if 4*h*w-N*(h+w)!=0:
            n=N*h*w/(4*h*w-N*(h+w))
            if n.is_integer() and n>0:
                print(h,int(n),w)
                exit()


Measured memory_bytes: 73632
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <algorithm>    // std::copy
#include <iterator>     // std::back_inserter
#include <set>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    vector<int> p(N);
    vector<int> pp(N);

    for(int i = 0; i < N ; i++){
        cin >> p[i];
        pp[i] = p[i];
    }

    sort(pp.begin(),pp.end());

    int count = 0;
    for(int i = 0; i < N ; i++){
        if(pp[i] != p[i]){
            count++;
        }
    }

    if(count % 2 == 0 && count / 2 < 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }




}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))

anslist = []

for i in range(1, n+1):
    if (i % 3 == 0) and (i % 5 == 0):
        continue
        # print('FizzBuzz', end=' ')
    elif i % 3 == 0:
        continue
        # print('Fizz', end=' ')
    elif i % 5 == 0:
        continue
        # print('Buzz', end=' ')
    else:
        anslist.append(i)
        # print(i, end=' ')

print(sum(anslist))

Measured memory_bytes: 30008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int table[100001];
void calc(int key) {
    rep3(i, 1, 100) { // 6^i
        int num = pow(key, i);
        if (num > 100000) break;
        rep3(j, num, 100001) {
            chmin(table[j], table[j - num] + 1);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    rep(i, 100001) table[i] = i;
    calc(6); calc(9);
    out(table[n]);
    // outa(table, n + 1);
}


Measured memory_bytes: 768
#include <stdio.h>
 
int main() {
 
  long long i,j,k,n,m,l,a,b,c;
  long long A[101][101] = {0};
  long long B[101][101] = {0};
  long long C[101][101] = {0};
 
  scanf("%lld %lld %lld",&n,&m,&l);
 
  for(j=0; j<n; j++) {
    for(i=0; i<m; i++) {
 
      scanf("%lld", &a);
      A[j][i] = a;
     
    }
  }
 
  for(j=0; j<m; j++){
    for(i=0;i<l;i++){
      scanf("%lld",&b);
      B[j][i] = b;
    }
  }
 
    for(i=0 ;i<n; i++) {
      for(j=0; j<l; j++){
    C[i][j] = 0;
    for(k=0;k<m; k++) {
       C[i][j] += A[i][k]*B[k][j];  
       /*    printf("%d ",C[i][j]); */
    }
    /* printf("\n"); */
      }
    }
 
 
     for(i=0; i<n; i++) {
      for(j=0; j<l; j++) {
    printf("%lld",C[i][j]);
    if(j !=l-1) {
      printf(" ");
    }
      }
      printf("\n");
      } 
 
    return 0;
 
  }


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
int n,ma,mb;
int a[50],b[50],c[50];
int dp[50][500][500];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>ma>>mb;
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i]>>c[i];
	memset(dp,63,sizeof(dp));
	dp[0][0][0]=0;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=400;j++){
			for(int k=0;k<=400;k++)if(dp[i][j][k]<=1e9){
				dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);//leave
				dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);//take
			}
		} 
	}
	int res=1e9;
	for(int j=ma;j<=400;j+=ma){
		int k=j/ma*mb;
		if(k>400)
			continue;
		res=min(res,dp[n+1][j][k]);
	}
	if(res==1e9)
		res=-1;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 49664
n,q = map(int, input().split())
s = input()

nums = [0]*n
for i in range(1,n):
  if s[i] == "C":
    if s[i-1] == "A": nums[i] += 1
  nums[i] += nums[i-1]
  
for _ in range(q):
  l,r = map(lambda x: int(x)-1, input().split())
  print(nums[r]-nums[l])

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

int main() {
  int N,K;
  cin>>N>>K;
  
  int count=0;
  vector<int> h(N);
  rep(i,N){
    cin>>h[i];
    if(h[i]>=K)
      ++count;
  }
  
  cout<<count<<endl;
  
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<vector<ll>> d(301,vector<ll>(301,1e18)); 
void warshall_floyd(int n) { // nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main(){
    ll N;
    cin >> N;
    vector<vector<ll>> A(N,vector<ll>(N));
    rep(i,N){
        rep(j,N){
            cin >> A[i][j];
            d[i][j] = A[i][j];
        }
    }
    warshall_floyd(N);
    rep(i,N){
        rep(j,N){
            if(d[i][j] != A[i][j]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    ll ans = 0;
    rep(i,N){
        REP(j,i+1,N){
            ans += d[i][j];
        }
    }
    rep(i,N){
        REP(j,i+1,N){
            rep(k,N){
                if(i == j) continue;
                if(j == k) continue;
                if(k == i) continue;
                if(d[i][j] == d[i][k] + d[k][j]){
                    ans -= d[i][j];
                    break;
                } 
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5008
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define MAX 200009
int a[MAX];
#define int long long
using namespace std; 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    #endif*/

	int T=1;
	//cin >> T;
	FOR1(tp, T)
	{
		//cout << "Case #" << i << ": ";
		int a, b; cin >> a >> b;
		cout << a*b;
		cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<int>num(N,0);
  for(int i=0;i<N;i++){
    cin >> num[i];
  }
  
  sort(num.begin(),num.end());
  
  int sum = 0;
  for(int i=0;i<N;i++){
    sum += num[i];
  }
  
  if(sum % 10 != 0)
    cout << sum << endl;
  else{
    bool all = true;
    for(int i=0;i<N;i++){
      if(num[i] % 10 != 0)
        all = false;
    }
    if(all)
      cout << 0 << endl;
    else{
      for(int i=0;i<N;i++){
        if(num[i] % 10 != 0){
          sum -= num[i];
          break;
        }
      }
        cout << sum << 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++)

int main()
{ 
  int n;
  cin >> n;
  set<int> a;
  rep(i,n){
    int x;
    cin >> x;
    a.insert(x);
  }
if(a.size()==n) cout << "YES" << endl;
else cout << "NO"<<endl;
return 0;
}

Measured memory_bytes: 9600
from collections import defaultdict


n, k = map(int, input().split())

cnt = 0
d = defaultdict(int)
for i in range(n):
    a, b = map(int, input().split())
    d[a] += b

d = sorted(d.items())

for i, j in d:
    cnt += j
    if cnt >= k:
        print(i)
        break



Measured memory_bytes: 14944
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}
class DPartition {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N, M;
    cin >> N >> M;
    vector<int> ans;
    for (int i = M / N; i >= 0; i--) {
      if (M % i == 0) {
        ans.emplace_back(i);
        break;
      }
    }
    cout << ans[ans.size() - 1] << endl;
  }
};


signed main() {
  DPartition solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ll;
typedef pair<ll, ll> P;

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll a_c = a/c;
  ll a_d = a/d;
  ll b_c = b/c;
  ll b_d = b/d;

  ll count_c,count_d,count_cd;
  if(a%c==0){
    count_c = b_c-a_c+1;
  }else{
    count_c = b_c-a_c;
  }
  if(a%d==0){
    count_d = b_d-a_d+1;
  }else{
    count_d = b_d-a_d;
  }

  if(c<d) swap(c,d);
  ll cd = c*d;
  ll r = c%d;

  while(r!=0){
    c = d;
    d = r;
    r = c%d;
  }
  cd = cd/d;

  ll a_cd = a/cd;
  ll b_cd = b/cd;

  if(a%cd==0){
    count_cd = b_cd-a_cd+1;
  }else{
    count_cd = b_cd-a_cd;
  }
  cout << b-a+1 - (count_c+count_d-count_cd) << endl;

  //cout << b-a+1 << " " << count_c << " " << count_d << " " << count_cd << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define mod 1000000007
long long dp[100005],fact[100005],inv[100005];
int arr[100005];
long long pow_log(long long x,int y)
{
	if (!y)
	return 1;
	long long ret=pow_log(x,y/2);
	ret=(ret*ret)%mod;
	if (y%2)
	ret=(ret*x)%mod;
	return ret;
}
int f(int n,int r)
{
	return (fact[n]*inv[r])%mod;
}
int main()
{
	int n;
	scanf("%d",&n);
	fact[0]=1;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&arr[i]);
		fact[i]=(fact[i-1]*i)%mod;
		dp[i]=(dp[i-1]*i+fact[i-1])%mod;
	}
	inv[n]=pow_log(fact[n],mod-2);
	for (int i=n-1;i>=0;i--)
	inv[i]=(inv[i+1]*(i+1))%mod;
	long long sum=0;
	for (int i=1;i<=n;i++)
	sum=(sum+arr[i]*((f(n,i)*dp[i]+f(n,n-i+1)*dp[n-i+1]-fact[n]+mod)%mod))%mod;
	printf("%lld",sum);
}

Measured memory_bytes: 2944
def main():
    s = input()

    sc = s.count('h')
    sh = s.count('i')

    if sc != sh:
        print('No')
        exit()

    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] != 'h':
                break
        else:
            if s[i] != 'i':
                break
    else:
        print('Yes')
        exit()

    print('No')

if __name__ == '__main__':
    main()

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

int main()
{
    int n = 0 ,d = 0;
    double dis = 0;
    int ans = 0;
    cin >> n >> d;
    double x,y;

    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        dis = sqrt(x * x + y * y);
        if(dis <= d)
        {
            ans++;
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 3816