akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin,(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int64 n; cin >> n;
		vector<int64> a(n + 1);
		vector<int64> b(n);
		rep(i, n + 1) {
			cin >> a[i];
		}
		rep(i, n) {
			cin >> b[i];
		}
		int64 ans = 0;
		rep(i, n) {
			//n番目の勇者でi番目のモンスターを倒しきれるだけ倒す
			int64 t = min(a[i], b[i]);
			//倒したモンスターの数だけ力を消費する
			ans += t;
			b[i] -= t;
			//i + 1番目のモンスターについて、残った力で倒しきれるだけ倒す、全部倒せる場合は全部
			t = min(a[i + 1], b[i]);
			//倒した数だけモンスターの数を減少させる
			a[i + 1] -= t;
			ans += t;
		}
		cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}



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

int sum=0;
typedef long long int LLI;

vector<LLI>ar;

void debug(vector<LLI>&v)
{
	cout<<v.size()<<" :";
	for(auto e:v) cout<<e<<" ";
	cout<<"  ";
	return;
}

int f(string& s,vector<LLI>&v)
{
	sort(v.begin(),v.end(),greater<int>());
	//debug(v);
	if(!v.size()){
		LLI num=0,p=1;
		LLI lo=0,hi=s.size()-1;
		for(LLI i=hi;i>=lo;--i) num+=(s[i]-'0')*p,p*=10;
		//cout<<"sum: "<<num<<"\n";
		ar.emplace_back(num);
		return num; 
	}
	if(v.size()==1){
		LLI num=0,val=0;
		LLI lo,hi=s.size()-1;
		lo=ceil(v[0]/2.0);
		LLI p=1;
		for(LLI i=hi;i>=lo;--i) num+=(s[i]-'0')*p,p*=10;
		val+=num;
		hi=lo-1,lo=0;
		p=1;
		num=0;
		for(LLI i=hi;i>=lo;--i) num+=(s[i]-'0')*p,p*=10;
		val+=num;
		//cout<<"sum: "<<val<<"\n";
		ar.emplace_back(val);
		return val;
	}
	//reverse(v.begin(),v.end());
	LLI hi=s.size()-1,lo;
	LLI val=0;
	for(LLI i=0;i<v.size();++i){
		LLI num=0;
		//if(i==v.size()-1) lo=0;
		lo=ceil(v[i]/2.0);
		LLI p=1; 
		for(LLI j=hi;j>=lo;--j) num+=(s[j]-'0')*p,p*=10;
		hi=lo-1;
		//cout<<num<<" ";
		val+=num; 
	}
	hi=lo-1,lo=0;
	LLI num=0,p=1;
	for(LLI j=hi;j>=lo;--j) num+=(s[j]-'0')*p,p*=10;
	val+=num;
	ar.emplace_back(val);
	//cout<<"\nsum: "<<val<<"\n";
	return val;
}

int find_sum(string& s,LLI cur,LLI hi,vector<LLI>&v)
{
	if(cur>hi) return f(s,v);
	sum+=find_sum(s,cur+2,hi,v);
	vector<LLI>q;
	for(auto e:v) q.emplace_back(e);
	q.emplace_back(cur);
	sum+=find_sum(s,cur+2,hi,q);
	return sum;
}

void solve()
{
	string s;
	cin>>s;
	LLI l=s.size();
	vector<LLI>v;
	if(l==1) cout<<s;
	else{
		LLI useless=find_sum(s,1,2*l-3,v);
		LLI ans=0;
		for(auto e:ar) ans+=e;
		cout<<ans;
	}
	return;
}

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

Measured memory_bytes: 256
#include <stdio.h>


int A[100][100],p[100];
void cal(int n)
{
  int i,l,j,k,b;
  for(l=2;l<=n;l++)
    {
      for(i=1;i<=n-l+1;i++)
	{
	  j = i + l - 1;
	  A[i][j] = 100000;
	  for(k=i;k<j;k++)
	    {
	      b = A[i][k] + A[k+1][j] + p[i-1] * p[k] * p[j];
	      if(A[i][j]>b) A[i][j]=b;
	    }
	}
    }
}

int main()
{

  int n=0,i;

  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d%d",&p[i-1],&p[i]);
    }

  for(i=1;i<=n;i++)
    {
      A[i][i]=0;
    }

  cal(n);
  printf("%d\n",A[1][n]);

  return 0;
  
  
}



Measured memory_bytes: 2144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int m = Integer.parseInt(br.readLine());
		System.out.println(48 - m);
	}
}

Measured memory_bytes: 23124
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

A,B,C,D = map(int,input().split())

ab1 = B // C -  (A-1) // C
ab2 = B // D -  (A-1) // D

lcd = lcm(C,D)

ab3 = B//lcd - (A-1)//lcd

ans = (B-A+1) - (ab1+ab2-ab3)

print(ans)

Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  vector<int> imos(n+1, 0);
  for(int i = 0; i < n; i++){
    imos[i+1] = imos[i] + a[i];
  }
  //cout << imos << endl;

  int ans = 1LL << 60;
  for(int i = 1; i < n; i++){
    ans = min(ans, abs(imos[i] - (imos[n] - imos[i])));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
using namespace std;
int main() {
	bool b = true;
	string s; cin >> s;
	string ans;
	for (int i = 0; i < s.size(); i++) {
		if (b&&s[i] == 'A') {
			ans += 'A';
			b = false;
		}
		else if (!b&&s[i] == 'Z') {
			ans += 'Z';
			b = true;
		}
	}
	if (ans.size() % 2 == 1)ans.pop_back();
	if (ans.size() == 0)cout << "-1\n";
	else cout << ans << endl;
}

Measured memory_bytes: 3212
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var A = new long[M];
            var B = new long[M];
            var C = new long[M];
            for (var i = 0; i < M; ++i)
            {
                var t = Sarray();
                A[i] = t[0];
                B[i] = t[1];
                t = Sarray();
                for (var j = 0; j < B[i]; ++j)
                    C[i] |= 1L << (int)(t[j] - 1);
            }
            var snum = (int)Pow(2, N);
            var state = new long[snum].Select(_ => (long)int.MaxValue).ToArray();
            state[0] = 0L;
            //for (var k = 0; k < N; ++k)
                for (var i = 0L; i < state.Length; ++i)
                {
                    for (var j = 0L; j < M; ++j)
                        state[i | C[j]] = Min(state[i | C[j]], state[i] + A[j]);
                }

            if (state[state.Length - 1] == int.MaxValue)
                WriteLine(-1);
            else
                WriteLine(state[state.Length - 1]);
        }
    }
}

Measured memory_bytes: 13396
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    for (x in 0..(N / 4)) {
        val n = N - 4 * x
        if (n >= 0 && n % 7 == 0) {
            println("Yes")
            return
        }
    }
    println("No")
}

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

int main(){
  int n , k;
  cin >> n >> k;
  vector<long long> v(n); 
  for (int i = 0 ; i < n ; i ++) {
    cin >> v.at(i);
  }

  for (int i = 0 ; i < n - k ; i ++) {
    if (v.at(i) < v.at(i + k)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 4840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x==3||x==5||x==7)System.out.println("YES");
		else System.out.println("NO");
		sc.close();
	}
}

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

int main(){
    string S;
    cin >> S;
    string T = "CODEFESTIVAL2016";
    int ans = 0;
    for(int i=0; i<16; i++)
        if(S[i] != T[i])
            ans++;
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n,s=0;
	cin>>n;
	vector<int> v(n);
	for( int &i:v){
		cin>>i;
	}
	for(int i=1;i<=n;i=i+2){
		if(v[i-1]%2 != 0)
			++s;
	}
	
	cout<<s;
	return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
int main(){
  long long n[10000],max=-1000000,min=1000000,sum=0,i,input;
  scanf("%lld",&input);
  for(i=0;i<input;i++){
    scanf("%lld",&n[i]);
    sum+=n[i];
  }
  max=n[0];
  min=n[0];
  for(i=1;i<input;i++){
    if(n[i]>max){
      max=n[i];
    }
    else if(n[i]<min){
      min=n[i];
    }
    else {}
  }
  printf("%lld %lld %lld\n",min,max,sum);
  return 0;
}



Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

int main(void){
    
    ll N,p;
    vector<ll> P;
    cin >> N;
    REP(i,N*N){
        cin >> p;p--;
        P.push_back(p);
    }
    
    ll Ans=0;
    ll D[514][514];
    bool F[514][514];
    bool G[514][514];
    
    REP(i,N){
        REP(j,N){
            D[i][j]=min({i,j,N-i-1,N-j-1});
            F[i][j]=false;
            G[i][j]=false;
        }
    }
    
    ll dx[4]={1,0,-1,0};
    ll dy[4]={0,1,0,-1};
    
    /*
    REP(i,N){
        REP(j,N){
            cout << D[i][j] << " ";
        }cout << endl;
    }cout << endl;*/
    
    REP(_,P.size()){
        ll i=P[_]/N;
        ll j=P[_]%N;
        
        Ans+=D[i][j];
        F[i][j]=true;
        vector<pair<ll,ll>> g;
        
        queue<pair<ll,ll>> Q;
        Q.push({i,j});
        G[i][j]=true;
        g.clear();
        g.push_back({i,j});
        
        while(!Q.empty()){
            ll u=Q.front().first;
            ll v=Q.front().second;
            Q.pop();
            
            g.push_back({u,v});
            G[u][v]=true;
            REP(k,4){
                ll y = u+dy[k];
                ll x = v+dx[k];
                if(!(0<=x&&x<N))continue;
                if(!(0<=y&&y<N))continue;
                if(G[y][x])continue;
                if(D[y][x]<=D[u][v]+1-(ll)F[u][v])continue;
                
                Q.push({y,x});
                D[y][x]=D[u][v]+1-(ll)F[u][v];
            }
        }
        
        REP(k,g.size()){
            G[g[k].first][g[k].second]=false;
        }
        g.clear();
        /*
        cout << i+1 MM j+1 << endl;
        REP(a,N){
            REP(b,N){
                if(F[a][b]){cout << "t";}else{cout << " ";}
                cout << D[a][b] << " ";
            }cout << endl;
        }cout << endl;
        */
    }
    
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 15620
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    if(n%2){
        cout<<"No\n";
        return 0;
    }
    for(int i=0; i<n/2; ++i){
        if(s[i]!=s[i+n/2]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define swap(a,b) ((a!=b)&&(a+=b,b=a-b,a-=b))
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int c[26],s[365][26]={{0}},type[365],candidate[365][4]={{0}};
void solve(int d)
{
  int now,since[26]={0},keep[26],rank[26];
  for(int i=0;i<d;i++)
  {
    now=0,since[type[i]]=i;
    for(int j=0;j<26;j++){keep[j]=s[i][j]+c[j]*(i-since[j]);rank[j]=j;}
    for(int j=0;j<26;j++)
    {
      for(int k=j+1;k<26;k++)
      {
        if(keep[j]<keep[k]){swap(keep[j],keep[k]);swap(rank[j],rank[k]);}
      }
    }
    now=rank[0],type[i]=now,since[now]=i;
    for(int j=0;j<4;j++){candidate[i][j]=rank[j+1];}
  }
}
int main()
{
  int D=IN(),i=0,j=0,M=0,t[365],sum=0,temp=0,update[26]={0};
  while(i<26){c[i++]=IN();}i=0;
  while(i<D){while(j<26){s[i][j++]=IN();}i++,j=0;}i=0;
  solve(D);
  while(i<1)
  {
    j=0;temp=type[i],sum+=s[i][temp];update[temp]=++i;
    while(j<26){sum-=c[j]*(i-update[j]);j++;}
  }
  temp=sum;
  int remain=4*D-1;j=0;
  while(remain--)
  {
    int d=remain/4,q=candidate[d][j],l0=-1,l1=-1,r0=D,r1=D,esc0=0,esc1=0,old=type[d];
    sum+=s[d][q]-s[d][type[d]];i=d-1;
    while(i>=0)
    {
      if(type[i]==type[d]&&!esc0){l0=i;esc0=1;}
      if(type[i]==q&&!esc1){l1=i;esc1=1;}
      if(esc0&esc1){break;}i--;
    }
    esc0=esc1=0;i=d+1;
    while(i<D)
    {
      if(type[i]==type[d]&&!esc0){r0=i;esc0=1;}
      if(type[i]==q&&!esc1){r1=i;esc1=1;}
      if(esc0&esc1){break;}i++;
    }
    sum-=c[type[d]]*(d-l0)*(r0-d);sum+=c[q]*(d-l1)*(r1-d);type[d]=q;
    if(temp<sum){temp=sum;}else{type[d]=old;}
    j++;if(j==3)j=0;
  }i=0;
  while(i<D){printf("%d\n",type[i++]+1);}
}

Measured memory_bytes: 1628
use std::io::Read;

fn main() {
    let (a, b, h) = {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        let a: usize = iter.next().unwrap().parse().unwrap();
        let b: usize = iter.next().unwrap().parse().unwrap();
        let h: usize = iter.next().unwrap().parse().unwrap();
        (a, b, h)
    };
    print!("{}", (a + b) * h / 2);
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<queue>

using namespace std;

const int MAX = 100000;

int parent(int table[], int child) {
	queue<int> q;

	while (table[child] != -1) {
		q.push(child);
		child = table[child];
	}
	while (!q.empty()) {
		table[q.front()] = child;
		q.pop();
	}
	return child;
}

int main() {
	int n, m, q;
	int table[MAX];

	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++)table[i] = -1;
	for (int i = 0; i < m; i++) {
		int s, t;
		scanf("%d %d", &s, &t);
		
		int ps = parent(table, s);
		int pt = parent(table, t);
		if (ps != pt) {
			table[ps] = pt;
		}
	}

	scanf("%d", &q);

	for (int i = 0; i < q; i++) {
		int s, t;
		
		scanf("%d %d", &s, &t);

		int ps = parent(table, s);
		int pt = parent(table, t);

		if (ps == pt) {
			printf("yes\n");
		}
		else {
			printf("no\n");
		}
	}
	return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cctype>
#include <stack>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long lolo;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ulolo;

const int maxn = (int)3e5 + 5;
const int INF = 0x3f3f3f3f;
const lolo inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int MOD = 1000000007;

template<class T>
inline void read(T &x) {
    x = 0; T flag = 1;char c;
    do { c = (char) getchar(); if (c == '-') break; } while (c < '0' || c > '9');
    if (c == '-') { c = '0', flag = -1;}
    do { x = x * 10 + c - '0';c = (char) getchar();} while (c >= '0' && c <= '9');
    x *= flag;
}
template<class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    x = x % 10;
    putchar('0' + x);
}

int main() {
//    freopen("../in.txt", "r", stdin);
    char str[110];
    scanf("%s", str);
    int len = strlen(str);
    int ans = 0;
    for (int i = 0; i < len/2; ++i) {
        if (str[i] != str[len-i-1]) {
            ++ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(int i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 100000+5
using namespace std;



int main()
{
	int n,x=0,y=0,z=0,p;
	si(n);
	rep(i,0,n)
	{
		si(p);
		if(p%4==0)
			x++;
		else if(p%2==0)
			y++;
		else
			z++;
	}
	int a=2*x+1+(y/2)*2;
	if(a>=n)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 256
def main():
    from sys import stdin, stdout

    def read():
        return stdin.readline().rstrip('\n')

    def read_array(sep=None, maxsplit=-1):
        return read().split(sep, maxsplit)

    def read_int():
        return int(read())

    def read_int_array(sep=None, maxsplit=-1):
        return [int(a) for a in read_array(sep, maxsplit)]

    def write(*args, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in args) + end)

    def write_array(array, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in array) + end)

    a, p = read_int_array()
    write((a * 3 + p) // 2)

main()


Measured memory_bytes: 38256
/*
g++ -std=c++11 -o2 -Wall ABC102A.cpp -o ./out/ABC102A.out
./out/ABC102A.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 1) n = 2;
  ll ans = n % 2 == 1 ? 2 * n : n;
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
using namespace std;
typedef pair <int, int> pii;
int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	string s, t;
	//long long n, A[1000000000];
	long long n, m;
	//int   y[100001], z[100001], x[10001] = {};
	pii y[100001];
	//pair<int, float> pii[100001];
	cin >> n;
	cin >> m;
	for (a = 0; a < m; a++)
	{
		cin >>b;
		cin >>c;
		y[a] = pii(b, c);
	}
	sort(y, y + m);
	//int temp;
	//for (i = 0; i < m - 1; i++) {
	//	for (j = m - 1; j > i; j--) {
	//		if (y[j - 1] > y[j]) {
	//			temp = y[j];        /* 交換する */
	//			y[j] = y[j - 1];
	//			y[j - 1] = temp;

	//			temp = z[j];        /* 交換する */
	//			z[j] = z[j - 1];
	//			z[j - 1] = temp;
	//		}
	//	}
	//}
	//cin >> a;
	//cin >> b;
	//cin >> c;
	//cin >> d;
	//for (a = 0; a < m; a++)
	//{
	//	cout << y[a].first << endl;

	//}for (a = 0; a < m; a++)
	//{
	//	cout << y[a].second << endl;

	//}
	//m = 0;
	b = 0;
	c = 0;
	for (a = 0; a < m; a++)
	{
		c = y[a].second;
		//cout << c << endl;

		b = min(b,c);
		
		if (y[a].first >= b)
		{
			d++;
			b = 100000000;
			a--;
		}
	}
	//for ( a = 1; a <= n; a++)
	//{
	//	for ( b = 0; b < m; b++)
	//	{
	//		if (a==y[b])
	//		{
	//			//c = 1;
	//			y[b] = 0;
	//			x[e] = b;
	//			e++;
	//			
	//		}
	//		if (a==z[b]&&y[b]==0)
	//		{
	//			while (e!=0)
	//			{
	//				e--;
	//				y[x[e]] = 0;
	//				z[x[e]] = 0;
	//			}
	//			/*for ( c = 0; c < m; c++)
	//			{
	//				if (y[c]==0)
	//				{
	//					y[c] = -1;
	//					z[c] = -1;
	//				}
	//			}*/
	//			d++;
	//		}
	//	}
	//}
	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	cout << d << endl;

	return 0;
}

Measured memory_bytes: 1024
A, B, C, X, Y = map(int, input().split())
ans = A*X+B*Y
for i in range(1, max(X, Y)+1):
    if i <= min(X, Y):
        ans = min(ans, ans+2*C-(A+B))
    else:
        if X > Y:
            ans = min(ans, ans-A+2*C)
        else:
            ans = min(ans, ans-B+2*C)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");


int main(){
    char a, b;
    cin >> a >> b;
    if(a < b){
      print("<");
    }else if(a > b){
      print(">");
    }else{
      print("=");
    }
   
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int N, M;
vector<int> E[9];
int kotae;

void sagasu(int A, int B) {
	if ((B >> A & 1) == 0) {
		B += 1 << A;
		for (auto itr : E[A]) {
			sagasu(itr, B);
		}

		if (B == ((1 << N + 1) - 2)) kotae++;
	}
	
}



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

	
	cin >> N >> M;

	rep(i, M) {
		int a, b;
		cin >> a >> b;
		E[a].pb(b);
		E[b].pb(a);
	}

	sagasu(1, 0);

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
using System;

namespace cf17_final_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] akb = new string[]
            {
                "AKIHABARA",
                "AKIHABAR",
                "AKIHABRA",
                "AKIHABR",
                "AKIHBARA",
                "AKIHBAR",
                "AKIHBRA",
                "AKIHBR",
                "KIHABARA",
                "KIHABAR",
                "KIHABRA",
                "KIHABR",
                "KIHBARA",
                "KIHBAR",
                "KIHBRA",
                "KIHBR"
            };
            Console.WriteLine(Array.IndexOf(akb,Console.ReadLine()) >= 0 ? "YES" : "NO");
        }
    }
}

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

using namespace std;

int main() {
    int v[5], answer = 0, last = 5, min = 10;
    for (int i = 0; i < 5; ++i) {
        cin >> v[i];
        answer += v[i];
        int d = v[i] % 10;
        if (d > 0 && d < min) {
            min = d;
            last = i;
        }
    }
    for (int i = 0; i < 5; ++i) {
        if (i != last && v[i] % 10 != 0) {
            answer += 10 - v[i] % 10;
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        """
        ノード数nの配列を作る
        親の番号を格納する
        -> 自分が根だった場合は、-(その集合のサイズ)とする
        作るときはparentの値を全て-1にする
        こうすると全てバラバラになる
        """
        self.parent = [-1 for _ in range(n)]
 
    def root(self, x):
        """
        要素xの根の番号を返す
        """
        if self.parent[x] < 0:
            # 自分が根
            return x
        # 要素xの親を要素xの根に変えておく(付け替える)
        # 次の呼び出しが早くなる
        self.parent[x] = self.root(self.parent[x])
        return self.parent[x]
 
    def size(self, x):
        """
        要素xの所属するグループの頂点数を調べる
        根のparentにサイズが格納されている
        """
        return -self.parent[self.root(x)]
 
    def merge(self, x, y):
        """
        xとyを結合する
        """
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
 
        #大きい方(x)に小さい方(y)をくっつけたい
        if self.parent[x] > self.parent[y]:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return True
    
    def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)

N,M = map(int,input().split())
ab = []
ans = 0
for i in range(M):
    a,b = map(int,input().split())
    ab.append([a,b])

for i in range(M):
    UF = UnionFind(N)
    for j in range(M):
        if i == j:
            continue
        UF.merge(ab[j][0]-1,ab[j][1]-1)
    if UF.size(0) == N:
        continue
    ans += 1

print(ans)


Measured memory_bytes: 41072
n = int(input())
r_min = int(input())
Rt = int(input())
g_max = Rt - r_min
r_min = min(Rt,r_min)

for _ in range(n - 2):
    Rt = int(input())
    g_max = max(g_max, Rt - r_min)
    r_min = min(Rt,r_min)
print(g_max)



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >> K;
	std::cin >> S;
	if(S.size()<=K){std::cout << S << std::endl;}
	else {std::cout << S.substr(0,K)<<"..." << std::endl;}
}

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

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


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

    if(Y%2==0&&2*X<=Y&&Y<=4*X){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



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

int main(){
  int N;
  cin>>N;
  vector<pair<pair<string,int>,int>> A(N);
  string S;
  int P;
  for(int i=0;i<N;i++){
    cin>>S;
    cin>>P;
    A[i]={{S,100-P},i+1};
  }
  sort(A.begin(),A.end());
  for(int i=0;i<N;i++){
    cout<<A[i].second<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    set<string> t, u;
    t.insert("a");
    for (int i = 0; i < n - 1; i++) {
        for (auto &e:t) {
            char m = 'a';
            for (auto &f:e)m = max(m, f);
            for (char j = 'a'; j <= m + 1; j++) {
                u.insert(e + j);
            }
        }
        t.clear();
        t = u;
        u.clear();
    }
    for (auto &e :t) cout << e << endl;
}

Measured memory_bytes: 18048
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int x[100];
signed main(){
	int a,ans=0;
	cin>>a;
	f(i,a){
		cin>>x[i];
		if(i)ans+=max((int)(0),x[i]-x[i-1]);
		else ans+=x[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

S = [list(input()) for i in range(H)]

for i in range(H):
    S[i].insert(0, ".")
    S[i].append(".")
S.insert(0, ["."]*(W+2))
S.append(["."]*(W+2))

filled = True
for i in range(1, H+2):
    for j in range(1, W+2):
        if (S[i][j] == "#") and (S[i][j-1] == S[i][j+1] == S[i-1][j] == S[i+1][j] == "."):
            filled = False

if filled:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
# coding: utf-8
# Here your code !
# -*- coding:utf-8 -*-
import sys
from datetime import time

def init():
    data = []
    try:
        while(True):
            line = raw_input()
            if not line: break
            data.append(line)
    except EOFError:
        pass
    return data

def valid(n):
    return (1 <= n <= 100)

def sec2hms(s):
    m , sec = dev_and_mod(s, 60)
    hour, mi = dev_and_mod(m, 60)
    return (hour, mi, sec)
    
def dev_and_mod(n, d):
    return (n/d, n%d)

def main():
    print "%d:%d:%d" % sec2hms(int(init().pop()))

if __name__ == '__main__':
    main()

Measured memory_bytes: 6532
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {

		 BufferedReader br = new BufferedReader(new
		 InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		int x = Integer.parseInt(br.readLine());
		int t = 0, h = 0;
		for (int i = 0; i < x; i++) {
			//System.out.println(i+":"+t+" " +h);
			String str = br.readLine();
			String[] fight = str.split(" ");
			if (fight[0].equals(fight[1])) {
				t++;
				h++;
			} else {
				boolean bl=false;
				for (int l = 0;(l<fight[0].length())&&(l<fight[1].length()); l++) {

					if (fight[0].charAt(l) == fight[1].charAt(l))
						continue;
					else if (fight[0].charAt(l) > fight[1].charAt(l)) {
						t += 3;bl=true;
						break;
					} else if(fight[0].charAt(l) < fight[1].charAt(l)){
						h += 3;bl=true;
						break;
					}
				}if(bl==false){
					if(fight[0].length()>fight[1].length())t+=3;
					else h+=3;
				}

			}
		}

		System.out.printf("%d %d%n", t, h);

	}

}

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

int a[200000];

int main(){

int N=0;
int i=0;
int c=0;

int hozon=0;
long long int x=0;
long long int y=0;

long long int ans=0;
long long int b=0;

cin>>N;

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

b=10000000000;


for(i=0;i<N-1;i++){
	if(i==0){
		x=a[i];
		for(int p=1;p<N;p++){
			y=y+a[p];
		}
	}else{
		x=x+a[i];
		y=y-a[i];
	}
	if(x-y<0){
		ans=y-x;
	}
	if(x-y>=0){
		ans=x-y;
	//	cout<<ans;
	}
	if(b>ans)b=ans;
}
cout<<b;


}

Measured memory_bytes: 1024
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
#include<cstdint>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
int main(){
      int W,H;
      cin>>W>>H;
      int N;
      cin>>N;
      int x[N],y[N],a[N];
      rep0(i,N) cin>>x[i]>>y[i]>>a[i];
      int w[H][W];
      rep0(j,H)rep0(k,W) w[j][k]=0;
      rep0(i,N){
            if(a[i]==1){
                  rep0(j,H){
                        rep0(k,x[i]){
                              w[j][k]=1;
                        }
                  }
            }
            if(a[i]==2){
                  rep0(j,H){
                        rep0(k,W-x[i]){
                              w[j][W-k-1]=1;
                        }
                  }
            }
            if(a[i]==3){
                  rep0(j,y[i]){
                        rep0(k,W){
                              w[j][k]=1;
                        }
                  }
            }
            if(a[i]==4){
                  rep0(j,H-y[i]){
                        rep0(k,W){
                              w[H-j-1][k]=1;
                        }
                  }
            }
      }
      int ans=0;
      rep0(j,H){
            rep0(k,W){
                  if(w[j][k]==0) ans++;
            }
      }
      /*rep0(j,H){
            rep0(k,W){
                  cout<<w[j][k];
            }
            cout<<endl;
      }*/
      cout<<ans<<endl;

      return 0;
}

Measured memory_bytes: 256
def frog(num,scaffold):
    result = [0] * num
    #result[0] = 0
    result[1] = abs(scaffold[0] - scaffold[1])
    if num > 2:
        for i in range(2,num):
            result[i] = min(result[i-1]+abs(scaffold[i-1]-scaffold[i]),result[i-2]+abs(scaffold[i-2]-scaffold[i]))
    #print(result)
    return result[num-1]

if __name__ == "__main__":
    N = int(input())
    h = list(map(int,input().split()))
    a = frog(N,h)
    print(a)



Measured memory_bytes: 13928
#include <stdio.h>
#pragma warning (disable:4996)

//prototype
int sum(int);

int main() {
	//input
	int N, M;
	(void)scanf("%d %d", &N, &M);

	//output
	int A, s = 0;
	for (int i = 0; i < M; i++) {
		(void)scanf("%d", &A);
		s += A;
	}
	if ((N - s) >= 0)printf("%d", N - s); else printf("-1");
}

Measured memory_bytes: 1708
#include <iostream>
#include <vector>
//#include <math.h>
//#include <string>
#include <cmath>
#include <iomanip>

int main();

//最初に素数リストを作成し、入力された値に対してリストを参照する。
int main(){
	int w;		//縦線の本数
	int n;		//横棒の本数
	int lines[31];		//ライン番号

	std::cin >> w >> n;
	
	//ライン番号初期化
	//範囲に注意
	for (int i = 1; i <= w; i++){
		lines[i] = i;
	}
	for (int i = 0; i < n; i++){
		int x;
		int y;
		char comma;

		std::cin >> x >> comma >> y;
		//交換処理
		int temp;
		temp = lines[x];
		lines[x] = lines[y];
		lines[y] = temp;
	}
	//結果出力
	//範囲に注意
	for (int i = 1; i <= w; i++){
		std::cout << lines[i] << std::endl;
	}

	//while (1);
	return 0;
}


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

int main()
{
	int S=0;
	int h=0,m=0;

	scanf("%d",&S);
	h=S/3600;
	S=S%3600;

	m=S/60;
	S=S%60;

	printf("%d:%d:%d\n",h,m,S);

	return 0;
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define MOD 998244353
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
 
int power(int x,int y,int mod) 
{ 
 	int ret = 1;
 	x = x % mod;
 	while (y){
 		if(y&1) ret = (ret*x)%mod;
 		y = y>>1;
 		x = (x*x)%mod;
    } 
    return ret%mod; 
}

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

void solve()
{	
	int n,w;
	cin>>n>>w;
	vector<int> dp(1e5+5,1e12+5);
	dp[0] = 0;
	vector<ii> inp(n);
	for (auto &x:inp)
		cin>>x.fi>>x.se;
	for (int i=0;i<n;i++){
		for (int j = 1e5+3;j>-1;j--){
			if (j-inp[i].se>=0){
			dp[j] = min(dp[j],dp[j-inp[i].se] + inp[i].fi);
			}
		}
	}
	for (int i=1e5+3;i>-1;i--){
		if (dp[i]<=w){
			cout<<i<<endl;
			return;
		}
	}


}
 
 
signed main(){
	// int t;
	// cin>>t;
	// while (t--)	
	solve();	
 
}
	

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

const int DIM = 1e5 + 5;

deque<int> deq;

int main(void) {
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    
    cout << ((a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0) ? "Possible" : "Impossible");
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <deque>
//#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using p = pair<int, int>;
#define rep(i,n)  for(int i = 0; i < n ; i++)

int main()
{
	int N;
	cin >> N;
	vector<int> first(N + 1);
	vector<int> second(N + 1);
	// 累積和を求める
	first.at(0) = 0;
	for (int i = 0; i < N; i++)
	{
		int a = 0;
		cin >> a;
		first.at(i + 1) = first.at(i) + a;
	}
	second.at(0) = 0;
	for (int i = 0; i < N; i++)
	{
		int a = 0;
		cin >> a;
		second.at(i + 1) = second.at(i) + a;
	}

	int result = 0;
    if(N == 1){cout << first.at(1) + second.at(1) << endl; return 0;}
	for (int i = 1; i < N; i++)
	{
		result = max(result, (first.at(i) - first.at(0) + second.at(N) - second.at(i -1)));
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
import math
N = int(input())
if N == 0:
    print(0)
    exit()
ans = ""
while N != 1:
    if N % 2 == 0:
        N //= (-2)
        ans = "0" + ans
    else:
        if N > 0:
            N //= (-2)
            N += 1
            ans = "1" + ans
        else:
            N //= (-2)
            N += 1
            ans = "1" + ans
ans = "1" + ans    
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ll t=1;
    //cin>>t;
    while(t--){
        int a;
        cin>>a;
        a=(3*a*a);
        cout<<a<<"\n";
    }
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, d;
	cin >> n >> d;
	vector<vector<int>> dist(n, vector<int>(d));
	for (int i = 0; i < n; ++i) 
		for (int j = 0; j < d; ++j) 
			cin >> dist[i][j];
	int p = 0, ret = 0;
	for (int i = 0; i < n; ++i) {
		for (int k = i+1; k < n; ++k){
			p = 0;
			for (int h = 0; h < d; ++h)
				if (k != i) p += abs(dist[i][h]-dist[k][h]) * abs(dist[i][h]-dist[k][h]);
			if (sqrt(p) == (int)sqrt(p)) ret++;
		}
	}
	cout << ret << '\n';
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;

void add_edge(int from,int to,mat &G,mat &rG){
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v,mat &G,vec &used,vec &vs){
  used[v]=1;
  for(int i=0;i<(int)G[v].size();i++){
    int to=G[v][i];
    if(!used[to])dfs(to,G,used,vs);
  }
  vs.push_back(v);
}

void rdfs(int v,int k,mat &rG,vec &used,vec &cmp){
  used[v]=1;
  cmp[v]=k;
  for(int i=0;i<(int)rG[v].size();i++){
    int to=rG[v][i];
    if(!used[to])rdfs(to,k,rG,used,cmp);
  }
}

int scc(mat &G,mat &rG,vec &cmp){
  int n=G.size();
  cmp=vec(n);
  vec vs, used(n,0);
  for(int v=0;v<n;v++){
    if(!used[v])dfs(v,G,used,vs);
  }
  
  int k=0;
  reverse(vs.begin(),vs.end());

  used=vec(n,0);
  for(int i=0;i<n;i++){
    int v=vs[i];
    if(!used[v])rdfs(v,k++,rG,used,cmp);
  }
  return k;
}


int main(){
  int N,M;
  cin>>N>>M;
  
  mat G(N),rG(N);
  for(int i=0;i<M;i++){
    int from,to;
    cin>>from>>to;
    add_edge(from,to,G,rG);
  }
  
  vec tmp;
  int SIZE = scc(G,rG,tmp);  
  
  set<int> A,B,C;
  for(int i=0;i<N;i++)A.insert(tmp[i]);
  for(int i=0;i<N;i++){
    for(int j=0;j<(int)G[i].size();j++){
      int from=i;
      int to=G[i][j];
      if( tmp[from] == tmp[to] )continue;
      
      B.insert(tmp[from]);
      C.insert(tmp[to]);
    }
  }

  int X=A.size()-C.size();
  int Y=A.size()-B.size();

  if(SIZE == 1){
    cout<<0<<endl;
  }else{
    cout<< max(X,Y) <<endl;
  }
  
  return 0;
}

Measured memory_bytes: 6300
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,g=0,n=0;
    cin >> a >> b >> c;
    if(a==5) g++;
    else n++;
    if(b==5) g++;
    else n++;
    if(c==5) g++;
    else n++;
    cout << (g==2?"YES":"NO");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int dp[3005][3005]; 
// dp[i][j] := sをi文字、tをj文字までみたときの答えの長さ

int main(void) {
	string s, t;
	cin >> s >> t;

	int szs = s.size();
	int szt = t.size();

	s = "A" + s;
	t = "A" + t;
	rrep (i, szs) rrep (j, szt) {
		if (s[i] == t[j]) {
			dp[i][j] = dp[i - 1][j - 1] + 1;
		}
		else {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}


	int i = szs;
	int j = szt;
	string ans = "";
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j]) {
			i--;
		}
		else if (dp[i][j] == dp[i][j - 1]) {
			j--;
		}
		else {
			ans += s[i];
			i--;
			j--;
		}
	}
	
	reverse(rng(ans));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35456
n = int(input())
a = list(map(int, input().split()))
count = 0

flag = True
while flag:
    flag = False
    for j in range(n-1, 0, -1):
        if a[j] < a[j-1]:
            x = a[j]
            a[j] = a[j-1]
            a[j-1] = x
            flag = True
            count = count + 1

print(*a)
print(count)


Measured memory_bytes: 5600
n = int(input())
w = list(map(int,input().split()))
ans = 1000
Ans = 1000
for i in range(1,n+1):
    front = []
    back = []
    front = w[:i]
    back = w[i:]
    diff = abs(sum(front) - sum(back))
    if diff < ans:
        ans = diff
        Ans = i
print(ans)

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

using namespace std;

typedef long long LL;

inline bool tri(LL a, LL b, LL c){
    return a < b + c;
}

int main(){
    int n;
    cin >> n;
    vector<LL> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<LL>());

    vector<LL> sum(n + 1);
    REP(i, n) sum[i + 1] = sum[i] + a[i];

    LL ans = 0;

    vector<LL> length;
    REP(i, n - 2) {
        if(tri(a[i], a[i + 1], a[i + 2])){
            length.push_back(a[i] + a[i + 1] + a[i + 2]);
            i += 2;
        }
        if(length.size() == 2) {
            ans = max(ans, accumulate(length.begin(), length.end(), 0LL));
            break;
        }
    }

    LL b[2][3] = {};
    int idx[2] = {};
    for(int comb = (1 << 3) - 1; comb < (1 << 6);){
        for(int i = 0; i + 6 <= n; i++){
            LL s = sum[i + 6] - sum[i];
            if(s < ans) break;

            memset(idx, 0, sizeof(idx));
            for(int j = 0; j < 6; j++) {
                b[ comb >> j & 1 ][ idx[comb >> j & 1]++ ] = a[i + j];
            }

            if(tri(b[0][0], b[0][1], b[0][2]) && tri(b[1][0], b[1][1], b[1][2])){
                ans = s;
            }
        }

        int x = comb & -comb, y = comb + x;
        comb = ((comb & ~y) / x >> 1) | y;
    }

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

Measured memory_bytes: 2584
#include <iostream>
#define INF 1e+9
using namespace std;

int main(){
	int n,a[10000] = {};
	int dp[2][5005][2];
	cin >> n;
	for(int i = 1;i < n;i++) cin >> a[i];
	for(int i = 0;i <= 5000;i++) {
		dp[0][i][0] = INF;
		dp[0][i][1] = INF;
		dp[1][i][0] = INF;
		dp[1][i][1] = INF;
	}
	dp[0][0][0] = 0;
	dp[0][0][1] = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n / 2;j++){
			dp[(i + 1) % 2][j + 1][0] = min(dp[i % 2][j][1] + a[i],dp[i % 2][j][0]);
			dp[(i + 1) % 2][j][1] = min(dp[i % 2][j][1],dp[i % 2][j][0] + a[i]);
		}
		for(int j = 0;j < n / 2;j++) {
			dp[i % 2][j][0] = INF;
			dp[i % 2][j][1] = INF;
		}
	}
	cout << dp[n % 2][n / 2][0] << endl;
	return 0;
}

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

int n,x,Out;
char s[2333];

int main(){
    scanf("%d",&n);
    scanf("%s", s + 1);
    for(int i = 1; i <= n; i++){
        if(s[i] == 'I') x++;
        else x--;
        Out = max(Out, x);
    }
    printf("%d\n",Out);
    return 0;

}


Measured memory_bytes: 256
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3
#sys.setrecursionlimit(int(1e+6))
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
MOD = int(1e+9) + 7

def main():
    n = i2n()
    p = i2nn()
    ans = 0
    for i in range(1, n-1):
        x, y, z = p[i-1:i+2]
        if x < y and y < z:
            ans += 1
        elif x > y and y > z:
            ans += 1
    print(ans)

main()


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    int cnt=0;
    rep(i,3)if(s[i]==t[i])++cnt;
    cout<<cnt<<endl;
    return 0;
    }


Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = list(map(int, sys.stdin.readline().split()))
S = sys.stdin.readline().rstrip()


def count(s):
    ret = 0
    k = K * 2
    for i in range(1, len(s)):
        if s[i] == s[i - 1]:
            ret += 1
        elif k > 0:
            k -= 1
            ret += 1
    return ret


a = count(S)
print(a)


Measured memory_bytes: 22780
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<ll> V;
typedef vector<V> VV;
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF = 1 << 28;
void solve(int a) { cout << (a ? "Yes" : "No") << endl; }

int main()
{
	int k, t;
	int ans = 0;

	cin >> k >> t;
	V a(t, 0);
	rep(i, t)
	{
		cin >> a[i];
	}
	sort(all(a));
	ll top = a[t - 1];
	//	cout<<top<<endl;
	rep(i, t - 1)
	{
		top -= a[i];
		//	cout<<a[i]<<" "<<top<<endl;;
	}
	//cout<<top<<endl;
	chmax(top, 0LL);
	
	cout << ((top==0)?0:top-1 )<< endl;
}


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

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int l;

double res = 0;
int main() {
  cin >> l;
  cout << fixed << setprecision(8) << ((double)l / 3) * ((double)l / 3) * ((double)l / 3);
}


Measured memory_bytes: 256