akhauriyash/Code-Regression huggingface dataset:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n, k = M()
l = LI()
l.sort(reverse=True)
ans = 0
for i in range(k):
    ans += l[i]
print(ans)

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

using namespace std;

const int MAX = 2 * 1000 * 100 + 11;
int parent[MAX];
int sizeOfSet[MAX];
int n, m;

void make_set(int node) {
	parent[node] = node;
	sizeOfSet[node] = 1;
}

int find_set(int node) {
	if(node == parent[node]) {
		return node;
	}
	
	return parent[node] = find_set(parent[node]);
}

void union_sets(int firstNode, int secondNode) {
	int parentOfFirstNode = find_set(firstNode);
	int parentOfSecondNode = find_set(secondNode);
	
	if(parentOfFirstNode != parentOfSecondNode) {
		if(sizeOfSet[parentOfFirstNode] < sizeOfSet[parentOfSecondNode])
			swap(parentOfFirstNode, parentOfSecondNode);
			
		parent[parentOfSecondNode] = parentOfFirstNode;
		
		sizeOfSet[parentOfFirstNode] += sizeOfSet[parentOfSecondNode];
	}
}

map<int, int> mp;

int main()
{
	cin >> n >> m;
	
	for(int i = 0; i < n; i++) {
		make_set(i);
	}
	
	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		union_sets(x, y);
	}
	
	for(int i = 1; i <= n; i++) {
		mp[find_set(i)]++;
	}
	
	int res = 0;
	for(auto it: mp) {
		res = max(res, it.second);
	}
	
	cout << res;
	return 0;
}


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

int main() {
	char c[20];
	int key;
	priority_queue<int>Q;
	while(1){
		cin>>c;
		if(c[2]=='s'){
			cin>>key;
			Q.push(key);
		}
		else if(c[2]=='t'){
			cout<< Q.top()<<endl;
			Q.pop();
		}
		else if(c[2]=='d'){
			break;
		}
	}
	return 0;
}


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

int main(){
	int n, h, w;
	std::cin>>n>>h>>w;

	std::cout<<(n-h+1)*(n-w+1)<<std::endl;

	return 0;
	
	
}

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

void algae(int r, int D, int x) {
  for (int i = 0; i < 10; i++) {
    int next_x = r * x - D;
    cout << next_x << endl;
    x = next_x;
  }
}

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  algae(r, D, x);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{  char b;
  scanf("%s",&b);
 if(b=='A'){
   puts("T");}
  if(b=='T'){
   puts("A");}
 if(b=='C'){
   puts("G");}
 if(b=='G'){
   puts("C");}
 return(0);}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    var numN =  readLine().orEmpty().toLong()
    val sqrtN = Math.sqrt(numN.toDouble()).toLong()

    val listA = mutableListOf<Long>()

    for(i in 1L until sqrtN + 1){
        if(numN % i == 0L){
            listA.add(i)
        }
    }

    var dist = numN
    var result = 1L
    listA.distinct().forEach {
        if(Math.abs(it - (numN / it)) < dist){
            dist = Math.abs(it - (numN / it))
            result = it
        }
    }

    
    println(digit(result,numN / result))

}


//桁数の大きい方の値
fun digit(a:Long,b:Long):Int{
    val digitA = a.toString().length
    val digitB = b.toString().length

    return if (digitA < digitB) digitB else digitA
}

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

#define int long long

using namespace std;

long long gcd(int a, int b){
  if(a < b) swap(a, b);
  if(b == 0) return (long long)a;
  return gcd(b, a % b);
}

int div2(int x){
  int cnt = 0;
  while(!(x & 1)){
    x = (x >> 1);
    cnt++;
  }
  
  return cnt;
}

int half_cm(int M, vector<int>& a){
  int n = a.size();
  
  int d2 = div2(a[0]);
  for(int i = 1; i < n; i++){
    if(d2 != div2(a[i])){
      return 0;
    }
  }
  
  long long l = a[0] / 2;
  for(int i = 1; i < n; i++){
    l = l * (long long)a[i] / (2 * gcd(l, a[i] / 2));
    if(l > M) return 0;
  }
  
  return (M - l) / (2 * l) + 1;
}

signed main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  
  cout << half_cm(M, a) << endl;
  
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
a = []
ans = 0
state = 1
for i in range(0,N):
	a.append(int(input()))
for i in range(0,N):
	for j in range(i+1,N):
		if a[i] == a[j]:
			state = 0
	if state:
		ans += 1
	state = 1
print(ans)


Measured memory_bytes: 3060
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__);
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__);


#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){

    SCIN(a,b);
    reverse(ALL(b));
   YES(a==b); 




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string a, b, c, s;
  in(s);
  ll k = 9999;
  ll m;
  rep(i, s.size() - 2){
    a = s[i];
    b = s[i + 1];
    c = s[i + 2];
    a = a + b + c;
    m = stoi(a) - 753ll;
    k = min(k, abs(m));
  }
  out(k);
  memi;
}

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

using std::cout;
using std::endl;
using std::cin;
using std::string;

int main(){
  long int n,sum=0;
  cin >> n;
  for(int i=1;i<=n;i++){
    if((i%3==0)||(i%5==0))
      sum+=0;
    else
      sum+=i;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

int main()
{
	string S;
	cin >> S;

	//
	rep(i, S.length() - 1)
	{
		if (S[i + 1] == S[i])
		{
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
		if(i + 2 < S.length() && S[i + 2] == S[i])
		{
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}

	//

	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <atcoder/all>
using namespace atcoder;

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int, Int> P;


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

    dsu UF(N);
    rep(i,M){
        int A, B; cin >> A >> B;
        A--; B--;
        UF.merge(A,B);
    }

    cout << UF.groups().size() - 1 << endl;
}

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

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


Measured memory_bytes: 256
n,q=gets.split.map(&:to_i)
arr=Array.new()
n.times do |i|
  name,time=gets.split
  time=time.to_i
  arr<<[name,time]
end
total=0
while !arr.empty?
  p,t=arr.shift
  if t<=q
    total+=t
    puts "#{p} #{total}"
  else
    t-=q
    total+=q
    arr<<[p,t]
  end
end

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

int main() {
    
	int n; cin >> n;
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		int d; cin >> d;
		mp[d]++;
	}
	int ans = 0;
	for (auto u : mp) {
		ans++;
	}
	cout << ans << endl;
    return 0;
}

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

int main() {
    int h, a;
    cin >> h >> a;
    int ans = 0;

    ans = h/a;
    if(h%a != 0) ans++;

    cout << ans << endl;

    return 0;
}

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

int main () {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A + B) > (C + D) ) {
    cout << "Left" << endl;
  }
  
  else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  
  else {
    cout << "Right" << endl;
  }
}

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

int a[100000];

int abs(int x) {
    return x > 0? x : -x;
}
int main(void) {
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);

    std::sort(a, a+n);
    k--;

    int mi=1000000000;
    for(int i=0; i+k<n; i++)
        if(mi > abs(a[i+k]-a[i]))
            mi = abs(a[i+k]-a[i]);
    printf("%d\n", mi);
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/







int A, B;
vector<string> S;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;
    A--; B--;

    {
        string s = "";
        rep(x, 0, 100) s += ".";
        S.push_back(s);

        rep(i, 0, 10) {
            int y = 1 + i * 2;
            string s = "";
            rep(x, 0, 50) {
                s += ".";
                if (B) {
                    s += "#";
                    B--;
                }
                else s += ".";
            }
            S.push_back(s);
            s = "";
            rep(x, 0, 100) s += ".";
            S.push_back(s);
        }
    }
    
    {
        string s = "";
        rep(x, 0, 100) s += "#";
        S.push_back(s);

        rep(i, 0, 10) {
            int y = 1 + i * 2;
            string s = "";
            rep(x, 0, 50) {
                s += "#";
                if (A) {
                    s += ".";
                    A--;
                }
                else s += "#";
            }
            S.push_back(s);
            s = "";
            rep(x, 0, 100) s += "#";
            S.push_back(s);
        }
    }

    int n = S.size();
    printf("%d %d\n", n, 100);
    rep(y, 0, n) printf("%s\n", S[y].c_str());
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int ans=0;
    int count=1;
    sort(a.begin(),a.end());
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            count++;
        }else{
            if(count%2!=0){
                ans++;
            }
            count=1;
    }
    if(i==n-1&&count%2!=0){
                ans++;
            }
    }
    if(n==1){
        ans = 1;
    }
    cout << ans << endl;
}

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

int N, M, sq, ans;

int main(){
  cin >> N >> M;
  sq = (int)ceil(sqrt(M));
  ans=1;
  for(int i=sq;i>=1;i--){
    if(M%i==0){
      if(M/i>=N&&i>=N) ans=max(max(M/i,i),ans);
      else if(M/i>=N) ans=max(i,ans);
      else if(i>=N) ans=max(M/i,ans);
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N, K, i;
	int P = 1;

	scanf("%d %d", &N, &K);

	for (i = 1; i < N; i++)
		{
			P *= (K - 1);
		}
		P *= K;
		printf("%d\n", P);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
void eratos(bool cp_list[],int max){
  for(int i=2;i<=max;i++){
    cp_list[i]=true;
  }
  cp_list[1]=false;
  for(int i=2;i<=max;i++){
    if(cp_list[i]){
      for(int j=i+i;j<=max;j+=i){
        cp_list[j]=false;
      }
    }
  }
}
int main(){
  ll n,ans=1,tmp,num;
  bool cp_list[1001];
  cin >> n;
  eratos(cp_list,1000);
  for(int i=2;i<=n;i++){
    if(cp_list[i]){
      tmp=0;
      num=i;
      while(num<=n){
        tmp+=n/num;
        num*=i;
      }
      ans*=(tmp+1);
      ans%=MOD;
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n,m;
  cin>>n>>m;
  cout<<(n-1)*(m-1)<<endl;
}

Measured memory_bytes: 3632
/* ALDS1_5_B: Koch Curve */

#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
using std::vector;

const double T_RAD = 60 * M_PI / 180.0;

struct Point {
    double x, y;
    Point(double _x, double _y) : x(_x), y(_y) {};
};

double one_third_in(double b, double e) {
    return (2 * b + e) / 3;
}

double two_thirds_in(double b, double e) {
    return (b + 2 * e) / 3;
}

double lotate_x(Point& a, Point& b) {
    return (b.x - a.x) * cos(T_RAD) - (b.y - a.y) * sin(T_RAD) + a.x;
}

double lotate_y(Point& a, Point& b) {
    return (b.x - a.x) * sin(T_RAD) + (b.y - a.y) * cos(T_RAD) + a.y;
}

void koch(int depth, vector<Point>& points, Point& p1, Point& p2) {
    if (depth == 0) return;

    Point s( one_third_in(p1.x, p2.x), one_third_in(p1.y, p2.y) );
    Point t( two_thirds_in(p1.x, p2.x), two_thirds_in(p1.y, p2.y) );
    Point u( lotate_x(s, t), lotate_y(s, t) );
    int next_depth = depth - 1;

    koch(next_depth, points, p1, s);
    points.push_back(s);

    koch(next_depth, points, s, u);
    points.push_back(u);

    koch(next_depth, points, u, t);
    points.push_back(t);

    koch(next_depth, points, t, p2);
}

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

    vector<Point> points;
    Point p1(0, 0), p2(100, 0);

    points.push_back(p1);
    koch(depth, points, p1, p2);
    points.push_back(p2);

    for (int i = 0; i < points.size(); i++) {
        Point& p = points[i];
        printf("%.8f %.8f\n", p.x, p.y);
    }

    return 0;
}

Measured memory_bytes: 1352
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        ans+=((n-1)/i);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int n;
    cin >> n;
    vector<int> two(3, 0);
    rep(i, n){
        int a, twonum=0;
        cin >> a;
        rep(j, 2){
            if(a%2==0){
                ++twonum;
            }else{
                break;
            }
            a /= 2;
        }
        ++two[twonum];
    }
    string ans = "Yes";
    if (two[2] < two[0]) {
      if (two[2] + two[0] != n || two[0] - two[2] != 1) {
        ans = "No";
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll a,b,c,d=0,e=1,i,j,k,l;
 cin>>a;
  vector<ll>v;
  for(i=1;i<=a;i++)
  {
  cin>>b;
  v.push_back(b);
  }
  for(i=0;i<a;i++)
  {
  if(v[i]==e){e++;d++;}
  }
 if(d==0)cout<<"-1\n";
 else {
   cout<<a-d<<endl;
      }
}

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

public class Main {

	public static final int mod = 1000000007;

	public static int count(int k) { // count number of ones in binary
		int c = 0;
		while (k > 0) {
			k &= k - 1;
			c++;
		}
		return c;
	}

	public static String pad(String s, int n) {
		for (int i = s.length(); i < n; i++) {
			s = "0" + s;
		}
		return s;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] s;
		boolean[][] matches = new boolean[n][n];
		for (int i = 0; i < n; i++) {
			s = br.readLine().split(" ");
			for (int j = 0; j < n; j++)
				matches[i][j] = Integer.parseInt(s[j]) == 1; // column = woman, row = man
		}

		int[][] dp = new int[n][(1 << n)];

		for (int i = 0; i < n; i++)
			dp[0][(1 << i)] = matches[i][0] ? 1 : 0; // last man left (think of as "there is about to be 0")

		// i is women left, j is women bitmask --> 1 = available, 0 = taken
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < (1 << n); j++) {
				if (count(j) != i) // no point if #women left != bitmask #women left
					continue;
				for (int k = 0; k < n; k++) { // for every possible man
					if (matches[k][i]) { // if the man and woman are compatible
						if (((1 << k) & j) == 0) { // and if the woman has been taken in this bitmask
							dp[i][j ^ (1 << k)] += dp[i - 1][j]; // where this woman is not taken += 
							dp[i][j ^ (1 << k)] %= mod; //indices not matching; working in future: "there is about to be"
						}
					}
				}
			}
		}

		int ans = 0;
		for (int i = 0; i < (1 << n); i++)
			ans = ans + dp[n - 1][i] % mod;
		System.out.println(ans);

	}

}


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

typedef int64_t i64;
typedef uint64_t ui64;

const int inf=1073741823;
const i64 llinf=4611686018427387903LL;

int main(void){
    int w,h,x,y,r;
    scanf("%i%i%i%i%i",&w,&h,&x,&y,&r);
    if(x>=r && y>=r && w>=x+r && h>=y+r) printf("Yes\n");
    else printf("No\n");
    return 0;
}



Measured memory_bytes: 3120
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

#include<array>

ll N, M;
vector<vector<bool>> connect(N, vector<bool>(N, false));

enum Dir {
    LEFT, RIGHT, UNDEFINEED
};

vector<Dir> dir;
vector<ll> tmp_nums;
bool isOK = true;

void dfs(ll v, Dir curr_dir) {
    dir[v] = curr_dir;
    tmp_nums[curr_dir]++;
    for (ll e = 0; e < N; e++) {
        if (e == v || !connect[v][e]) {
            continue;
        }

        Dir next_dir = (curr_dir == RIGHT ? LEFT : RIGHT);
        if (dir[e] == UNDEFINEED) {
            dfs(e, next_dir);
        } else if (dir[e] != next_dir) {
            isOK = false;
        }
    }
}

int main() {
    cin >> N >> M;
    connect.resize(N, vector<bool>(N, true));
    for (ll i = 0; i < M; i++) {
        ll A, B;
        cin >> A >> B;
        A--; B--;
        connect[A][B] = connect[B][A] = false;
    }

    //とりあえず二部グラフを作って配分の数を記録していく
    dir.resize(N, UNDEFINEED);
    vector<vector<ll>> nums;
    for (ll i = 0; i < N; i++) {
        if (dir[i] != UNDEFINEED) {
            continue;
        }
        tmp_nums.assign(2, 0);
        dfs(i, LEFT);
        nums.push_back(tmp_nums);
    }

    if (!isOK) {
        cout << -1 << endl;
        return 0;
    }

    vector<bool> dp(N + 1, false);
    dp[0] = true;
    for (auto num : nums) {
        for (ll i = N; i >= 0; i--) {
            if (!dp[i]) {
                continue;
            }
            dp[i] = false;
            dp[i + num[0]] = dp[i + num[1]] = true;
        }
    }

    ll l;
    for (ll i = 0; i <= N / 2; i++) {
        if (dp[i]) {
            l = i;
        }
    }

    ll r = N - l;
    cout << l * (l - 1) / 2 + r * (r - 1) / 2 << endl;
}

Measured memory_bytes: 384
N = int(input())
li = []
for i in range(N):
  a = list(input())
  a.sort()
  li.append("".join(a))
  
dic = {}
li2 = []
for i in range(len(li)):
  if not li[i] in dic:
    dic[li[i]] = 1
    li2.append(li[i])
  else:
    dic[li[i]] += 1

b = 0
for i in range(len(li2)):
  c = dic[li2[i]]
  if c == 1:
    b += 0
  else:
    b += c*(c-1)/2
print(int(b))

Measured memory_bytes: 20036
input()
nums = list(map(int, input().split()))
lis = [num - (i + 1) for i, num in enumerate(nums)]
cnt = 0
i = 0
while i < len(lis):
    if lis[i] == 0:
        cnt += 1
        if i == (len(lis) - 1):
            break
        if lis[i + 1] == 0:
            i += 1
    i += 1
print(cnt)

Measured memory_bytes: 14008
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    ll x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

int dp[100002];
int n, k, v[102];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];
    for(int i = 1; i <= k; ++i)
    {
        for(int j = 1; j <= n; ++j)
            if(i - v[j] >= 0 && !dp[i - v[j]])
                dp[i] = 1;
    }
    if(dp[k])
        cout << "First";
    else
        cout << "Second";
    return 0;
}


Measured memory_bytes: 640
from fractions import gcd

N = int(input())
As = list(map(int, input().split()))
re_As = As[::-1]
gcds = [0]*(N)
rgcds = [0]*(N)
gcds[0] = 0
rgcds[0] = 0

for i in range(N-1):
    gcds[i+1] = gcd(As[i], gcds[i])
    rgcds[i+1] = gcd(re_As[i], rgcds[i])

rgcds = rgcds[::-1]

ans = [0]*(N+1)

for i, (s, r) in enumerate(zip(gcds, rgcds)):
    ans[i] = gcd(s, r)
    
print(max(ans))

Measured memory_bytes: 89580
class UnionFind:
  def __init__(self, n):
    self.parent = [-1] * n
    self.rank = [1] * n
    self.count = [1] * n

  def get_root(self, i):
    if self.parent[i] < 0:
      return i
    else:
      self.parent[i] = self.get_root(self.parent[i])
      return self.parent[i]

  def is_same_tree(self, i, j):
    return self.get_root(i) == self.get_root(j)

  def merge(self, i, j):
    i = self.get_root(i)
    j = self.get_root(j)
    if i == j:
      return

    if self.rank[i] > self.rank[j]:
      self.parent[j] = i
      self.rank[i] = max(self.rank[i], self.rank[j] + 1)
      self.count[i] += self.count[j]
    else:
      self.parent[i] = j
      self.rank[j] = max(self.rank[j], self.rank[i] + 1)
      self.count[j] += self.count[i]


N, M = map(int, input().split())
uf = UnionFind(N)
for _ in range(M):
  a, b = [int(i) - 1 for i in input().split()]
  uf.merge(a, b)
print(len([_ for _ in uf.parent if _ == -1])-1)

Measured memory_bytes: 77056
#include<iostream>
#include<map>
#include<cstdio>
using namespace std;

map<double, int> t[4];


int main()
{
  int aa;
  double bb;
  for(int i = 0; i < 3; i++)
  {
    for(int j = 0; j < 8; j++)
    {
      cin >> aa >> bb;
      t[i][bb] = aa;
    }
  }
  for(int i = 0; i < 3; i++)
  {
    map<double, int>::iterator it = t[i].begin();
    printf("%d %2.2f\n", (*it).second, (*it).first);
    it++;
    printf("%d %2.2f\n", (*it).second, (*it).first);
    it++;
    for(;it != t[i].end(); it++)
      t[3][(*it).first] = (*it).second;
  }
  map<double, int>::iterator it = t[3].begin();
  printf("%d %2.2f\n",  (*it).second, (*it).first);
  it++;
  printf("%d %2.2f\n",  (*it).second, (*it).first);
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll D, N;
  cin >> D >> N;

  ll c_10 = 0;
  ll c_100 = 0;
  ll c_10000 = 0;

  ll ans = 0;
  rep(i, 100000000000) {
    if (i == 0) continue;
    if (D == 0 && c_10 == N) {
      COUT(i - 1);
      return 0;
    }
    if (D == 1 && c_100 == N) {
      COUT(i - 1);
      return 0;
    }
    if (D == 2 && c_10000 == N) {
      COUT(i - 1);
      return 0;
    }
    if (i % 100 != 0) {
      c_10++;
    }
    if (i % 10000 == 0 && (i / 10000) % 100 != 0) {
      c_10000++;
    }
    if (i % 100 == 0 && (i / 100) % 100 != 0) {
      c_100++;
    }
  }
  COUT(ans);

  return 0;
}

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

using namespace std;
using ll = long long;
const ll inf = 9000000000000000;

int main() {
	int n, m, l;
	cin >> n >> m >> l;
	ll g1[n + 2][n + 2];
	ll g2[n + 2][n + 2];

	for (int i = 1 ; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			g1[i][j] = inf;
			g2[i][j] = inf;
		}
		g1[i][i] = 0;
		g2[i][i] = 0;
	}	

	for (int i = 0; i < m; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		g1[a][b] = g1[b][a] = c;
	}

	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				g1[i][j] = min(g1[i][j], g1[i][k] + g1[k][j]);
			}
		}
	}

	int q; cin >> q;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (g1[i][j] <= l) {
				g2[i][j] = g2[j][i] = 1;
			}
		}
	}

	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				g2[i][j] = min(g2[i][j], g2[i][k] + g2[k][j]);
			}
		}
	}

	while (q--) {
		int s, t; cin >> s >> t;
		ll ans = g2[s][t];
		if (ans == inf) ans = 0;
		ans--;
		cout << ans << endl;
	}
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
ll min(ll a,ll b){
  if(a<b)return a;
  return b;
}
int main(){
  ll n,a,b,L,ans;
  cin>>n>>a>>b;
  L=n/(a+b);
  ans=L*a+min(n-L*(a+b),a);
  cout<<ans;
}

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

def main():
    N, M, R = map(int, input().split())
    Rs = list(map(int, input().split()))

    INF = 100000*200*200
    dp = [[INF for _ in range(N)] for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        dp[a-1][b-1] = c
        dp[b-1][a-1] = c

    for i in range(N):
        for j in range(N):
            for k in range(N):
                dp[j][k] = min(dp[j][k], dp[j][i]+dp[i][k])


    def ind(i, R, rem, l, ans):
        if i == R:
            ans.append(l)
            return ans
        for r in rem:
            nl = l[:]
            nl.append(r)
            nr = rem[:]
            nr.remove(r)
            ans = ind(i+1, R, nr, nl, ans)
        return ans

    inds = ind(0, R, [i for i in range(R)], [], [])

    for k, ind in enumerate(inds):
        D = 0
        for j in range(R-1):
            D += dp[Rs[ind[j]]-1][Rs[ind[j+1]]-1]
        if k == 0:
            ans = D
        ans = min(ans, D)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 61020
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define rrep(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define lli long long int
#define vi vector<int> 

using namespace std;

void p(int x) {
	cout << x << endl;
}

void pp(string s) {
	cout << s << endl;
}

int main() {
	vector<int> q;
	int ans[10];

	char c;
	while (cin >> c) {
		if (c == '0')q.push_back(0);
		if (c == '1')q.push_back(1);

		if (c == 'B') {
			if (!q.empty()) q.erase(q.end()-1);
		}
	}

	rep(i, 0, q.size())cout << q[i];
	
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll Mod=1e9+7;
int n,cot=0,f[200005],t[200005];
int pre[200005];
ll pp[200005][2];
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&t[i]);
    for(int i=1; i<=n; i++)
        if(t[i]!=t[i-1])
            f[++cot]=t[i];
    pp[1][0]=1;
    pre[f[1]]=1;
    for(int i=2; i<=cot; i++)
    {
        pp[i][0]=(pp[i-1][0]+pp[i-1][1])%Mod;
        pp[i][1]=(pp[i][1]+pp[pre[f[i]]][1]+pp[pre[f[i]]][0])%Mod;
        pre[f[i]]=i;
    }
    printf("%lld\n",(pp[cot][0]+pp[cot][1])%Mod);
}


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

int main() {
    int N[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K; 
    cout << N[K-1] << endl;

    return 0;
}


Measured memory_bytes: 256
//A - Station and Bus
//#include <iostream>
//#include <cstdio>
//#include <algorithm>
//#include <cstring>
//using namespace std;
//string s;
//int cnt;
//int main() {
//	cin >> s;
//	if (s[0] == 'A') cnt++;
//	if (s[1] == 'A') cnt++;
//	if (s[2] == 'A') cnt++;
//	if (cnt == 0 || cnt == 3) {
//		puts("No");
//	} else {
//		puts("Yes");
//	}
//	return 0;
//}
//B - Count Balls
//#include <iostream>
//#include <cstdio>
//#include <algorithm>
//#include <cstring>
//using namespace std;
//long long n, a, b;
//int main() {
//	cin >> n >> a >> b;
//	cout << n / (a + b) * a + min(a, n % (a + b));
//	return 0;
//}
//C - Tax Increase
//#include <iostream>
//#include <cstdio>
//#include <algorithm>
//#include <cstring>
//using namespace std;
//int a, b;
//int main() {
//	cin >> a >> b;
//	for (int i = b * 10; i < b * 10 + 10; i++) {
//		if ((int)(i * 0.08) == a) {
//			cout << i << endl;
//			return 0;
//		}
//	}
//	cout << -1 << endl;
//	return 0;
//}
//
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
using namespace std;
deque<char> s;
string tmp;
bool tag;//0:正序，1:倒序 
int q;
int main() {
	cin >> tmp;
	for (int i = 0; i < tmp.length(); i++) {
		s.push_back(tmp[i]);
	}
	cin >> q;
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			tag = !tag;
		} else {
			int f;
			char c;
			cin >> f >> c;
			if (tag == 0) {
				if (f == 1) s.push_front(c);
				else s.push_back(c);
			} else {
				if (f == 2) s.push_front(c);
				else s.push_back(c);
			}
		}
	}
	if (tag == 0) {
		while (!s.empty()) {
			cout << s.front();
			s.pop_front();
		} cout << endl;
	} else {
		while (!s.empty()) {
			cout << s.back();
			s.pop_back();
		} cout << endl;
	}
	return 0;
}

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

int main(){
    char token[100]={};
    unsigned long long a=0,b=0,c=0;
    unsigned long long left=0,right=0;
    while(fgets(token, sizeof(token), stdin)!=NULL){
        a=atoi(strtok(token, " "));b=atoi(strtok(NULL, " "));c=atoi(strtok(NULL, " "));
        right=c-a-b;right*=right;
        left=4*a*b;
        if(right>left&&c>a+b) printf("Yes");
        else printf("No");
    }
    return 0;
}





Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b;
    ans=a-2*b;
    Cout(max(ans,0LL));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int A,B,K;
  cin>>K>>A>>B;
  int judge=0;
  for(int i=A;i<=B;i++){
    if(i%K==0) judge++;
  }
  if(judge==0) cout<<"NG"<<endl;
  else cout<<"OK"<<endl;
  
  return 0;
}

Measured memory_bytes: 3636
use proconio::*;

type Deq = std::collections::VecDeque<(i64, f64)>;

struct Solver {
    deq: Deq,
    tv: f64,
    v: i64,
    up: i64,
    iu: f64,
}

impl Solver {
    fn new(up: i64) -> Self {
        Solver {
            deq: Deq::new(),
            tv: 0f64,
            v: 0,
            up: up,
            iu: 1.0 / up as f64,
        }
    }
    fn push(&mut self, t: i64, v: i64) {
        while self.v + v > self.up {
            let po = self.deq.front_mut().unwrap();
            if self.v + v - po.0 >= self.up {
                self.tv -= po.0 as f64 * po.1;
                self.v -= po.0;
                self.deq.pop_front();
            } else {
                let sub = po.0 - (self.up - (self.v - po.0) - v);
                self.tv -= sub as f64 * po.1;
                self.v -= sub;
                po.0 -= sub;
                break;
            }
        }
        let mut t = t as f64;
        let mut v = v;
        self.tv += t * v as f64;
        self.v += v;
        while self.deq.back().map_or(false, |p| p.1 > t) {
            let (a, b) = self.deq.pop_back().unwrap();
            t = (t * v as f64 + b * a as f64) / (v + a) as f64;
            v += a;
        }
        self.deq.push_back((v, t));
    }
    fn find(&self) -> f64 {
        self.tv * self.iu
    }
}

#[fastout]
fn run() {
    input! {
        n: usize,
        w: i64,
        p: [(i64, i64); n],
    }
    let mut solver = Solver::new(w);
    for (t, v) in p {
        solver.push(t, v);
        let ans = solver.find();
        println!("{:.7}", ans);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 32480
#include<iostream>
using namespace std;
int main(){
    int number;
    int i=1;
    
    
    
    
    while(1<3){
        cin >> number;
        if(number == 0){
            break;
        }
        
                cout << "Case " << i << ": " << number << endl;

        i++;
    }
    
    return 0;
}


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


int main(){
    int i,j,k;
    cin >> i >> j >> k;
    int s = 0;
    for(int tmp = i; tmp <= j; tmp++){
        if(k %  tmp == 0){
            s ++;
        }
    }
    cout << s << endl;
    return 0;
}


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

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

using namespace std;

using ll = long long;

using P = pair<int,int>;
int main() {

int n ;
cin >>n  ;
vector<int> X(n) ;
rep(i,n){
    cin>>X[i] ;
}
sort(X.begin(), X.end())  ;
int p=X[0] ;
int q=X[n-1] ;

ll ans = 1e9 ;
for(int i=p ; i< q+1 ; i++){
    ll sum=0 ;
    rep(j,n)
    sum +=  (X[j]-i)*(X[j]-i) ; 
     ans=min(ans ,sum) ;


}
cout << ans <<endl ;


  return 0;
}

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

int N, S[100];

int main(){
    cin >> N;
    for(int i=0;i<N;i++)    cin >> S[i];

    int ans = accumulate(S, S+N, 0);

    if(ans % 10 == 0){
        int mini = ans;
        for(int i=0;i<N;i++){
            if(S[i] % 10 != 0)    mini = min(mini, S[i]);
        }
        ans -= mini;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/* ****HARRYoo7**** */
/* ****I_LOVE_M.E**** */
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		string s;
		cin>>s;
		ll sum=0;
		rep(i,0,s.size())
		sum+=(s[i]-'0');
		ll ans=0;
		ans+=9*(s.size()-1);
		ans+=(s[0]-1-'0');
		ans=max(ans,sum);
		cout<<ans;		
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<string>
#include<cmath>

using namespace std;

int main(){
    double n = 0;
    cin >> n;
    double cands = n * (100.0/108.0);
    double candb = n * (100.0/109.0);
    for(double i = 1; i < 46298; i++){
        double curr = i;
        curr = curr * 1.08;
        curr = floor(curr);
        if(curr == n){
            cout << i;
            return 0;
        }
    }
    cout << ":(";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back 
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int> 
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second 
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0); 
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;

int n,w;
vpi v;

void solve(){
    cin>>n>>w; v.resize(n);
    rep(i,0,n) cin>>v[i].x>>v[i].y;
    int ans[n][w+1];mem(ans,0);
    rep(i,0,n){
        rep(j,1,w+1){
            if(i) ans[i][j]=ans[i-1][j];
            if(v[i].x>j) continue;
            if(i) ans[i][j]=max(ans[i-1][j],ans[i-1][j-v[i].x]+v[i].y);
            else ans[i][j]=v[i].y;
        }
    }
    cout<<ans[n-1][w];
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;                                                                                                                  
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

const long long mod = 998244353;

void milkshake() {
  int n, k;
  cin >> n >> k;
  vector<int> l(k), r(k);
  for(int i = 0; i < k; i++) {
    cin >> l[i] >> r[i];
  }
  vector<int> dp(n+1);
  vector<int> dps(n+1);
  dp[1] = dps[1] = 1;
  for(int i = 2; i <= n; i++) {
    for(int j = 0; j < k; j++) {
      int li = i - r[j];
      li = max(li, 1);
      int ri = i - l[j];
      if(ri < 1) continue;
      dp[i] = ((long long)dp[i] + (long long)dps[ri] - dps[li-1]) % mod;
    }
    dps[i] = ((long long)dps[i-1] + (long long)dp[i]) % mod;
  }
  cout << (dp[n] + mod) % mod << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) milkshake();

  return 0;
}


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

int main(){
    char a[6];
    for(int i=0;i<6 ;i++){
        cin >> a[i];
    }

    if ((a[2] == a[3]) && (a[4] == a[5])) 
    {
        cout << "Yes" << endl;
        
    } else
    {
        cout << "No" << endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

#define INF 1e18
#define MOD 1000000007
//#define DEBUG

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::default_random_engine e(seed);
std::mt19937 rng((int) seed);

void solvetask() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++) if(s[i] != t[i]) ans++;
    cout << ans << endl;

}

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

    int t = 1;

    while(t--) solvetask();
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N;
ll A[105000];
vector<ll> v;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    ll xorsum = 0;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        xorsum ^= A[i];
    }
    for(int i = 1; i <= N; i++) {
        A[i] &= ~xorsum;
    }
    for(int i = 1; i <= N; i++) {
        ll now = A[i];
        for(int j = 0; j < v.size(); j++) {
            chmin(now, now ^ v[j]);
        }
        if(now == 0) continue;
        for(int j = 0; j < v.size(); j++) {
            chmin(v[j], v[j] ^ now);
        }
        v.push_back(now);
        sort(v.begin(), v.end(), greater<ll>());
    }
    ll tmp = 0;
    for(int i = 0; i < v.size(); i++) {
        chmax(tmp, tmp ^ v[i]);
    }
    cout << tmp * 2 + xorsum << endl;
    return 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    ll h;
    int n;
    cin >> h >> n;
    ll kill = 0;
    rep(i, n)
    {
        int a;
        cin >> a;
        kill += a;
    }
    string ans = "";
    if (kill >= h)
        ans = "Yes";
    else
        ans = "No";
    c(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=610;
const ll mod=(1e9)+7;
int n,K,a[maxn],b[maxn],s[maxn];
ll g[maxn],dp[maxn][maxn],ans;
bool in(int l,int r,int x) {
	return l<=x&&x<=r;
}
int main() {
	read(n); read(K);
	for (int i=1;i<=K;i++) {
		read(a[i]),read(b[i]);
		s[a[i]]=s[b[i]]=1;
	}
	g[0]=1; n*=2;
	for (int i=1;i<=n;i++) s[i]+=s[i-1];
	for (int i=2;i<=n;i+=2) g[i]=g[i-2]*(i-1)%mod;
	for (int i=1;i<=n;i++)
	for (int j=i;j<=n;j++) {
		bool flag=1; int cnt=s[j]-s[i-1];
		for (int k=1,t1,t2;k<=K;k++) {
			t1=in(i,j,a[k]); t2=in(i,j,b[k]);
			if (t1+t2==1) { flag=0; break; }
		}
		if (!flag||(j-i+1-cnt)%2==1) continue;
		dp[i][j]=g[j-i+1-cnt];
		for (int k=i;k<j;k++)
			dp[i][j]+=mod-dp[i][k]*g[j-k-s[j]+s[k]]%mod,dp[i][j]%=mod;
		ans+=g[n-(j-i+1)-(K*2-cnt)]*dp[i][j]%mod; ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;


int main() {
	//cout << fixed << setprecision(10);
	long long int n, m, a[200005] = {}, b[200005] = {}, c = 22222220, d, w, h;
	string str;
	cin >> n >> str;
	for (int i = 0; i < n; i++) {
		if (str[i] == '#') {
			a[i + 1] = a[i] + 1;
		}
		else {
			a[i + 1] = a[i];
		}
	}

	for (int i = n; i >= 0; i--) {
		if (str[i] == '.') {
			b[i] = b[i + 1] + 1;
		}
		else {
			b[i] = b[i + 1];
		}
	}
	c = min(a[n], b[0]);
	for (int i = 0; i < n; i++) {
		if (a[i] + b[i] < c) {
			c = a[i] + b[i];
		}
	}


	cout << c;

}

Measured memory_bytes: 3716