akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <ios>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(void) {
    ios::sync_with_stdio(false);

    while(true) {
        int n = 0;
        int m = 0;
        cin >> n;
        cin >> m;
        if(n == 0) {
            break;
        }

        map<int, int> vertical;
        map<int, int> lateral;
        vector<int> road_v;
        vector<int> road_l;
        for(int i = 0; i < n; ++i) {
            int h;
            cin >> h;
            road_v.push_back(h);
        }
        for(int i = 0; i < m; ++i) {
            int w;
            cin >> w;
            road_l.push_back(w);
        }
        for(int i = 0; i < n; ++i) {
            int sum = 0;
            for(int j = i; j < n; ++j) {
                sum += road_v[j];
                vertical[sum] += 1;
            }
        }
        for(int i = 0; i < m; ++i) {
            int sum = 0;
            for(int j = i; j < m; ++j) {
                sum += road_l[j];
                lateral[sum] += 1;
            }
        }
        int result = 0;
        for(auto& pair: vertical) {
            auto& key = pair.first;
            result += vertical[key] * lateral[key];
        }
        cout << result << endl;
    }

    return 0;
}

Measured memory_bytes: 32228
H,N= map(int,input().split())

a = []
b = []

for i in range(N):
  a_dash,b_dash = map(int,input().split())
  a.append(a_dash)
  b.append(b_dash)

#dp[i+1][j] = i番目までの魔法で体力jのモンスターに
#勝つことができる、魔力の最小値
INF = 10**9
dp = [[INF for _ in range(H+1)] for _ in range(N+1)]

#体力0のモンスターは初めからデスしている
for i in range(N+1):
  dp[i][0] = 0

for i in range(N):
  for j in range(H+1):
    if a[i] > j:
      dp[i+1][j] = min(dp[i][j],b[i])
    else:
      dp[i+1][j] = min(dp[i][j],dp[i+1][j-a[i]]+ b[i])

print(dp[N][H])


Measured memory_bytes: 125788
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;


int main(){
    ll n; cin>>n;
    vector<pair<pair<string,ll>,ll>>a(n);
    rep(i,n){
        string s; ll c; cin>>s>>c;
        a[i]=make_pair(make_pair(s,-c),i+1);
    }
    sort(a.begin(),a.end());
    rep(i,n){
        cout<<a[i].second<<endl;
    }

}








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int count=0;
  for(int i=a;i<=b;i++){
    int a2=i/1000;
    int b3=i%100;
    int b2=b3/10+(b3%10)*10;
    if(a2==b2){
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}


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

int main()
{
	int N,M,X,Y;
	int x[105],y[105];
	bool data[205];
	bool ans=false;
	for(int i=0;i<205;i++)data[i]=true;
	cin >> N >> M >> X >> Y;
	for(int i=0;i<N;i++)cin >> x[i];
	for(int i=0;i<M;i++)cin >> y[i];
	
	for(int i=0;i<=X+100;i++)data[i]=false;
	for(int i=Y+101;i<=200;i++)data[i]=false;
	
	int maxx=x[0],miny=y[0];
	for(int i=0;i<N;i++){
		if(x[i]>maxx)maxx=x[i];
	}
	for(int i=0;i<M;i++){
		if(y[i]<miny)miny=y[i];
	}
	for(int i=0;i<=maxx+100;i++)data[i]=false;
	for(int i=miny+101;i<=200;i++)data[i]=false;
	
	for(int i=0;i<=200;i++){
		if(data[i]==true){
			ans=true;
			break;
		}
	}
	if(ans==true)cout << "No War";
	else cout << "War";
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define int long long

using namespace std;

signed main() {
	int a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	
	if (v <= w) {
		cout << "NO\n";
		return 0;
	}
	
	int d = abs(a - b);
	if (d <= (v - w) * t) cout << "YES\n";
	else cout << "NO\n";
	
	return 0; 
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
 
#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)
 
typedef long long ll;
 
using namespace std;
 
int main ()
{
  string S,Srep;
  ll acnt,res = 0;
 
  cin >> S;
 
  REPI(S.size()-1)
  {
    if (S[i] == 'A')
      Srep += 'A';
    else if (S[i] == 'B' && S[i+1] == 'C')
    {
      Srep += 'D';
      i++;
    }else{
      Srep += S[i];
    }
  }
 
  acnt = 0;
  REPI(Srep.size ())
  {
    if (Srep[i] == 'A')
      acnt++;
    else if (Srep[i] == 'D')
      res += acnt;
    else
      acnt = 0;
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3912
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXH=8;
const int MAXW=8;

int h,w;
char g[MAXH][MAXW+1];

bool ok() {
	int x=0,y=0;
	while(true) {
		if(g[x][y]!='#') return false; else g[x][y]='@';
		if(x==h-1&&y==w-1) break;
		if(x+1<h&&g[x+1][y]=='#') { ++x; continue; }
		if(y+1<w&&g[x][y+1]=='#') { ++y; continue; }
		return false;
	}
	REP(x,h) REP(y,w) if(g[x][y]=='#') return false;
	return true;
}

void run() {
	scanf("%d%d",&h,&w); REP(x,h) scanf("%s",g[x]);
	printf("%s\n",ok()?"Possible":"Impossible");
}

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


Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;
int d[15][15];
int main(void)
{
    int n,m,sum=0,cnt=0;
    int temp;
    cin >> n >> m;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin >> d[i][j];
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
        {
            sum=0;
            for(int k=0;k<m;k++)
            {
                sum+=(d[i][k]-d[j][k])*(d[i][k]-d[j][k]);
            }
            temp=sqrt((double)sum);
            if(temp*temp==sum)
                cnt++;
        }
    cout << cnt;
    return 0;
}

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

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

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

    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+7;

int bio[150];

int main() {
	string s;
	cin >>s;
	int n = s.size();
	for (int i=0 ; i<n ; i++) bio[s[i]]++;
	if (n == 26) {
		for (int i=n-1 ; i>=0 ; i--) {
			for (char c = s[i]+1 ; c<='z' ; c++) {
				if (bio[c] == 0) {
					s[i] = c;
					cout <<s.substr(0, i+1)<<endl;
					return 0;
				}
			}
			bio[s[i]] = 0;
		}
		cout <<-1<<endl;
	} else {
		for (char i='a' ; i<='z' ; i++) {
			if (!bio[i]) {
				s += i;
				cout <<s<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main() {
 
    int a, b;
 
    while (cin >> a >> b) {
        int n = 1;
        for(int i = 0; ; i++) {
            if (a + b < n)  {
                cout << i << endl;
                break;
            }
            n = n * 10;
        }
    }
      
    return 0;
 
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define M 200005
#define mo 998244353
#define lowbit(x) x&-x
using namespace std;
long long Pow[M];
int n,B[M<<1],len,C[M<<1];
void Add(int x){
	while(x<=n*2){
		C[x]++;
		x+=lowbit(x);
	}
}
int query(int x){
	int res=0;
	while(x){
		res+=C[x];
		x-=lowbit(x);
	}
	return res;
}
struct ll{
	int x,y;
}A[M];
bool cmpx(ll a,ll b){
	return a.x<b.x;
}
int main(){
	scanf("%d",&n);
	Pow[0]=1;
	for(int i=1;i<=n;i++)Pow[i]=Pow[i-1]*2%mo;
	for(int i=1;i<=n;i++)scanf("%d%d",&A[i].x,&A[i].y),B[++len]=A[i].x,B[++len]=A[i].y;
	sort(B+1,B+len+1);
	len=unique(B+1,B+len+1)-B-1;
	long long ans=1ll*n*(Pow[n]-1)%mo;
	for(int i=1;i<=n;i++){
		A[i].x=lower_bound(B+1,B+len+1,A[i].x)-B;
		A[i].y=lower_bound(B+1,B+len+1,A[i].y)-B;
		ans=(ans-Pow[i-1]+1+mo)%mo;
		ans=(ans-Pow[i-1]+1+mo)%mo;
		ans=(ans-Pow[n-i]+1+mo)%mo;
		ans=(ans-Pow[n-i]+1+mo)%mo;
	}
	sort(A+1,A+n+1,cmpx);
	for(int i=1;i<=n;i++){
		int k=query(A[i].y);
		ans=(ans+Pow[k]-1)%mo;//<x,<y
		ans=(ans+Pow[i-k-1]-1)%mo;//<x,>y
		Add(A[i].y);
	}
	memset(C,0,sizeof(C));
	for(int i=n;i>=1;i--){
		int k=query(A[i].y);
		ans=(ans+Pow[k]-1)%mo;
		ans=(ans+Pow[n-i-k]-1)%mo;
		Add(A[i].y);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>

using namespace std;


int main() {
	int n, ka, kb;
	int a, b;
	vector<pair<int, int> > dst;
	while (cin >> n && n != 0) {
		a = b = 0;
		while (n-->0 && cin >> ka >> kb) {
			if (ka > kb)
				a += (ka + kb);
			else if (ka < kb)
				b += (ka + kb);
			else {
				a += ka;
				b += kb;
			}
		}
		dst.push_back(pair<int, int>(a, b));
	}
	for (vector<pair<int, int> >::iterator it = dst.begin(); it < dst.end(); it++)
		cout << (*it).first << " " << (*it).second << endl;
	return 0;
}


Measured memory_bytes: 3040
#include <iostream>

int main(){
    int N;std::cin >> N;
    std::string S;std::cin >> S;

    if(N%2 != 0){
        std::cout << "No";
        return 0;
    }

    std::string T = S.substr(0, N/2);
    std::string T2 = S.substr(N/2, N/2);

    if(T == T2){
        std::cout << "Yes" ;
    }
    else{
        std::cout << "No" ;
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1e9 + 7;

string L;
int64_t dp[2][100003];

// O(log a)
int64_t powmod(int64_t a, int64_t p) {
    int64_t value = 1;
    for (int64_t mul = a; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
        if (p & 1) value = (value * mul) % MOD;
    }
    return value;
}

int64_t recursive(int b, int i) {
    if(i >= L.size()) return 1;
    if(dp[b][i] >= 0) return dp[b][i];
    if(b) {
        if (L[i] == '0') {
            return dp[b][i] = recursive(b, i + 1);
        } else {
            return dp[b][i] = (recursive(b, i + 1) * 2 + recursive(0, i + 1)) % MOD;
        }
    } else {
        return dp[b][i] = powmod(3, L.size() - i);
    }
}

int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    cin >> L;
    for(int b = 0; b < 2; b++) {
        for(int i = 0; i < L.size(); i++) {
            dp[b][i] = -1;
        }
    }
    cout << recursive(1, 0) << endl;
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


const ll MOD = 1e9 + 7;


const int SZ = 312345;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};

const int MAX_N = 112345;

ll A[MAX_N];

int main2() {
  int N = nextInt();
  int K = nextInt();
  REP(i, N) A[i] = nextInt();
  sort(A, A+N);

  mint ans = 0;
  REP(i, N) {
    ans += mint(A[i]) * choose(i, K-1);
  }
  REP(i, N) {
    ans -= mint(A[i]) * choose(N-1-i, K-1);
  }
  cout << ans.x << endl;
  return 0;
}

int main() {
  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 8576
import sys
n, m, x, y = map(int, input().split())
x_city = list(map(int, input().split()))
y_city = list(map(int, input().split()))

for z in range(x+1, y+1):
    if max(x_city) < z <= min(y_city) :
        print("No War")
        sys.exit()
print("War")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll a, b;
  cin >> a >> b;

  ll x = b - a;

  cout << (x*(x-1)/2 - a) << endl;

  return 0;
}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N,M;
    cin>>N>>M;

    vector<ll> H(N);
    rep(i,N){
        cin>>H[i];
    }

    ll a,b;
    vector<vector<ll>> ab(N);
    rep(i,M){
        cin>>a>>b;
        --a;
        --b;
        ab[a].push_back(b);
        ab[b].push_back(a);

    }
    ll ans = 0;
    vector<ll> flag(N);
    ll tmp_ans;
    rep(i,N){
        if(flag[i]==1) continue;
        tmp_ans = 1;
        for(auto v:ab[i]){
            if(H[i]<=H[v]){
                tmp_ans = 0;
                break;
            }
        }
        ans += tmp_ans;
    }

    cout<<ans<<"\n";
	

	
	return 0;
}

Measured memory_bytes: 10592
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] price = new int[n];
		for(int i = 0; i < n; i++){
			price[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
			for(int j = i; j < n; j++){
				if(price[i] > price[j]){
					int tmp = price[i];
					price[i] = price[j];
					price[j] = tmp;
				}
			}
		}
		int res = 0;
		for(int i = 0; i < k; i++){
			res += price[i];
		}
		System.out.println(res);
	}

}

Measured memory_bytes: 38868
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

public class Main{

	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
	   int  a= fs.nextInt();
	   int b=fs.nextInt();
	   int c=fs.nextInt();
	   int k=fs.nextInt();
	   int i=0;
	   while(i<k) {
		   if(a>=b) {
			   b=b*2;
			   i++;
		   }
		   else {
			   break;
		   }
	   }
	   while(i<k) {
		   if(b>=c) {
			   c=c*2;
			   i++;
		   }
		   else {
			   break;
		   }
	   }
	   if(a<b&&b<c) {
		   System.out.println("Yes");
	   }
	   else {
		   System.out.println("No");
	   }
	   
	}
	static void sort(int[] a ) {
		ArrayList<Integer> l = new ArrayList<>();
		for(int i:a) l.add(i);
		Collections.sort(l);
		for(int i=0;i<l.size();i++) a[i]=l.get(i);
	}
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 32732
n, m = gets.split.map(&:to_i)

xs = gets.split.map(&:to_i)
xs.sort!

if m == 1
  puts 0
elsif m == 2
  if n == 1
    puts xs[1] - xs[0]
  else
    puts 0
  end
else
  diff = []
  for i in 0..(m-2) do
    diff << xs[i+1] - xs[i]
  end

  diff.sort! { |a, b| b<=>a }

  diff.slice!(0, n - 1)
  puts diff.inject(:+).to_i
end

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n;
    cin >> n;
    ll ret=0;
    for(ll i=0;i<n;i++){
        ll a;
        cin >> a;
        ret+=a-1;
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#![doc = " # Bundled libraries"]
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
fn main() {
    input! { n : usize , ab : [(Usize1 , Usize1) ; n] , }
    let mut mx = 0;
    let mut cur = 0;
    for (a, b) in ab {
        if a == b {
            cur += 1;
            mx = std::cmp::max(mx, cur);
        } else {
            cur = 0;
        }
    }
    if mx >= 3 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,a,b;
	cin >> n >> a >> b;
	if(n == 1){
		cout << "Hello World ";
	}
	else{
		cout << a+b;
	}
	return 0;
}





Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<math.h>
#include<queue>
#include<vector>
#include<algorithm>
#define Max (int)1e9
#define MAX2 (int)1e5+5
#define MOD ((int)1e9+7)
using namespace std;



int main(){
	int n,l,i;
	scanf("%d%d",&n,&l);
	int tmp = 0;
	for(i=0;i<n;i++){
		tmp += l+i;
	}
	int min = Max,val,ans;
	for(i=0;i<n;i++){
		val = tmp - (l+i);
		if(min > fabs(tmp - val)){
			min = fabs(tmp - val);
			ans = val;
		}
	}
	printf("%d\n",ans); 
	return 0;
}



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

long long MAX_E = 2005;
long long MAX_V = 1005;
long long INF = 1e10;

struct edge {long long from, to, cost; };

vector<edge> es(MAX_E);
vector<long long> d(MAX_V);
long long v, e;

// s 番目の頂点から各頂点への最短距離を求める
// true なら s からたどり着ける負の閉路が存在する
bool bellman_ford(long long s) {
    for (long long i = 0; i < v; i++) d[i] = INF;
    d[s] = 0;
    for (long long i = 0; i < v; i++) {
        bool update = false;
        for (long long j = 0; j < e; j++) {
            edge ed = es[j];
            if (d[ed.from] != INF && d[ed.to] > d[ed.from] + ed.cost) {
                d[ed.to] = d[ed.from] + ed.cost;
                update = true;

                if (i == v - 1) return true;
            }
        }
        if (!update) break;
    }
    return false;
}


int main() {
    long long r;
    cin >> v >> e >> r;

    for (long long i = 0; i < e; i++) {
        cin >> es[i].from >> es[i].to >> es[i].cost;
    }

    bool is_negative = bellman_ford(r);

    if (is_negative) cout << "NEGATIVE CYCLE" << endl;
    else {
        for (long long i = 0; i < v; i++) {
            if (d[i] == INF) cout << "INF" << endl;
            else cout << d[i] << endl;
        }
    }
}




Measured memory_bytes: 3164
import copy
import itertools
import sys

if sys.version[0] == '2':
    range, input = xrange, raw_input

drc = [(-1, 0), (0, 1), (1, 0), (0, -1)]
C_NUM = 6


while True:
    H, W, C = map(int, input().split())
    if not (H | W | C):
        break
    board = [[int(x) - 1 for x in input().split()] for _ in range(H)]
    ans = 0
    for ope in itertools.product(range(C_NUM), repeat=5):
        # print(ope)
        if ope[0] == board[0][0] or ope[-1] != C - 1 or any(ope[i] == ope[i + 1] for i in range(4)):
            continue
        ps = [(0, 0)]
        tmp_board = copy.deepcopy(board)
        for color in ope:
            now_c = tmp_board[0][0]
            if now_c == color:
                continue

            for r, c in ps:
                tmp_board[r][c] = color
            stack = ps[:]
            while stack:
                r, c = stack.pop()
                for dr, dc in drc:
                    nr, nc = r + dr, c + dc
                    if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == now_c:
                        tmp_board[nr][nc] = color
                        stack.append((nr, nc))
                        ps.append((nr, nc))
        for r, c in ps:
            tmp_board[r][c] = -1
        stack = ps[:]
        while stack:
            r, c = stack.pop()
            for dr, dc in drc:
                nr, nc = r + dr, c + dc
                if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == C - 1:
                    tmp_board[nr][nc] = -1
                    stack.append((nr, nc))
        cand = sum(row.count(-1) for row in tmp_board)
        if cand > ans:
            ans = cand
    print(ans)

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n, k; cin >> n >> k;

    vector<int> d(k);
    for (int i = 0; i < k; ++i) {
        cin >> d[i];
    }

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

        int match = true;

        while (t > 0) {
            for (auto j : d) {
                if (t % 10 == j) {
                    match = false;
                    break;
                }
            }
            t /= 10;
        }

        if (match) {
            cout << n + i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n;
pair<ll, ll> p[200005];
ll INF = 10000000000;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	ll mama = -1, mimi = INF, mami = INF, mima = -1;
	FOR(i, n) {
		ll x, y;
		cin >> x >> y;
		if (x > y) swap(x, y);
		mimi = min(mimi, x);
		mima = max(mima, x);
		mami = min(mami, y);
		mama = max(mama, y);
		p[i] = make_pair(x, y);
	}
	ll res = (mama - mami) * (mima - mimi);

	sort(p, p+n);

	ll ma = p[n-1].first, mi = INF;
	FOR(i, n-1) {
		mi = min(mi, p[i].second);
		ma = max(ma, p[i].second);
		res = min(res, (mama - mimi) * (ma - min(mi, p[i+1].first)));
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
//		List<Integer> x =new ArrayList<Integer>();
		String str=new String();
		int[] a = new int[26];
		String[] eng = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n"
				      ,"o","p","q","r","s","t","u","v","w","x","y","z"};
		do{
			str = scan.next();
			for(int i=0;i<str.length() ;i++){
				for(int j = 0 ; j < eng.length ;j++ ){
					if( eng[j].equalsIgnoreCase(String.valueOf(str.charAt(i)))){
						a[j]++;
					}
				}

			}
		}while(scan.hasNext());


		
		for(int j = 0 ; j < eng.length ;j++ ){
			System.out.println(eng[j]+" : "+a[j]);
			}

	}
}







//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Scanner;
//
//public class Main {
//	public static void main(String[] args) {
//		Scanner scan = new Scanner(System.in);
//		List<Integer> n = new ArrayList<Integer>();
//		List<Integer> x = new ArrayList<Integer>();
//		List<Integer> count = new ArrayList<Integer>();
//
//		 for(int i=0;;i++){
//			 n.add(i, scan.nextInt());
//			 x.add(i, scan.nextInt());
//			 count.add(i, 0);
//			 if(n.get(i)==0 && x.get(i)==0) break;
//		 }
//
//
//
//   for(int h=0;;h++){
//		 if(n.get(h)==0 && x.get(h)==0) break;
//		 for(int i=1;i<=n.get(h);i++){
//			 for(int j=i;j<=n.get(h);j++){
//				 if(i==j)continue;
//				 for(int k=j;k <= n.get(h);k++){
//					 if(i==k || j==k)continue;
//					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
//				 }
//			 }
//		 }
//
//			System.out.println(count.get(h));
//   }
//	}
//
//}
//
//

Measured memory_bytes: 29180
'use strict'

function Main(input) {
  const N = Number(input.split("\n")[0].split(" ")[0])
  const Q = Number(input.split("\n")[0].split(" ")[1])
  const abList = input.split("\n").slice(1, N).map(x => x.split(" ").map(x => Number(x)))
  const pxList = input.split("\n").slice(N).map(x => x.split(" ").map(x => Number(x)))
  
  const nodeList = []
  for(let i=0; i<N; i++) {
    nodeList.push(new Node(i+1))
  }
  for(let i=0; i<N-1; i++) {
    nodeList[abList[i][0]-1].addChild(nodeList[abList[i][1]-1])
  }

  for(let i=0; i<Q; i++) {
    nodeList[pxList[i][0]-1].addPoint(pxList[i][1])
  }

  for(let i=0; i<N; i++) {
    nodeList[i].addPointToChild()
  }

  let ans = ""
  for(let i=0; i<N; i++) {
    ans += nodeList[i].point + " "
  }
  console.log(ans.trim())
}

class Node {
  constructor(nodeName) {
    this.name = nodeName
    this.parent = null
    this.childrenArray = []
    this.point = 0
  }
  
  addChild(childNode) {
    this.childrenArray.push(childNode)
    childNode.parent = this
  }

  addPoint(point) {
    this.point += point
  }

  addPointToChild() {
    for(const child of this.childrenArray) {
      child.addPoint(this.point)
    }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())


Measured memory_bytes: 167608
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


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


if __name__ == '__main__':
    b, c = map(int, input().split())

    for i in range(b):
        s = input()
        print(s)
        print(s)





Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define plint pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ll n,a,b,x,y,ans=0;
    cin >> n >> a >> b;
    x = n/(a+b);
    ans+=(x*a);
    y = n % (a+b);
    if(1<=y && y<=a){
        ans+=y;  
    }else if(a<y){
        ans+=a;
    }//else y==0
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,q,ans=0;
	string s;
	cin>>n;
	vector <int> eat(n),point(n),bonus(n-1);
    rep(i,n) cin>>eat[i];
    rep(i,n) cin>>point[i];
    rep(i,n-1) cin>>bonus[i];
    rep(j,n) ans+=point[j];
    rep(k,n-1){
        if(eat[k]+1==eat[k+1]){
            ans+=bonus[eat[k]-1];
            //cout<<ans;
        }
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        cout << 'x';
    }
    cout << endl;
}

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

using namespace std;

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

int main(){
    ll n, k;
    cin >> n >> k;
    priority_queue<P> que1;
    rep(i, n) {
        ll t, d;
        cin >> t >> d;
        t--;
        que1.push(P(d, t));
    }
    ll a[n];
    rep(i, n) a[i] = 0;
    ll num = 0;
    ll ans = 0;
    priority_queue<P, vector<P>, greater<P> > que2;
    for (int i = 0; i < k; i++){
        P p = que1.top();
        que1.pop();
        if(a[p.second] == 0) num++;
        a[p.second]++;
        ans += p.first;
        que2.push(p);
    }
    ans += num * num;
    ll sm = ans;
    for (int i = num + 1; i <= k; i++){
        
        while (!que1.empty()){
            P p1 = que1.top();
            que1.pop();
            if (a[p1.second] != 0) continue;
            P p2;
            while(true){
                p2 = que2.top();
                que2.pop();
                if(a[p2.second] > 1){
                    a[p2.second]--;
                    break;
                }
            }
            a[p1.second]++;
            sm = sm - p2.first - (i - 1) * (i - 1) + p1.first + (i * i);
            break;
        }
        ans = max(ans, sm);
    }
    cout << ans << endl;
}



Measured memory_bytes: 5616
s=list(input())
N=len(s)
if N==3:
  if s[0]==s[2]:
    print("Yes")
  else:
    print("No")
else:
  tmp=s[0:int((N-1)/2)]
  tmp_rev=tmp[::-1]

  tmp2=s[int((N+3)/2)-1:]
  tmp2_rev=tmp2[::-1]

  if tmp==tmp_rev and tmp2==tmp2_rev and s==s[::-1]:
    print("Yes")
  else:
    print("No")

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

ll F0[100], X0[100], Y0[100], A0[100], T0[100];

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

    for(int i=0;i<N;i++){
        scanf("%lld %lld %lld %lld %lld", F0+i, A0+i, T0+i, X0+i, Y0+i);
    }

    ll longest[2] = {-1, -1}, shortest[2] = {-1, -1};
    for(int i=0;i+1<N;i++){
        if(T0[i] != T0[i+1] || A0[i] == A0[i+1]){continue;}

        ll df = F0[i+1] - F0[i],
            dx = X0[i+1] - X0[i],
            dy = Y0[i+1] - Y0[i],
            dist2 = dx * dx + dy * dy;

        if(dist2 > longest[T0[i]]){
            longest[T0[i]] = dist2;
            shortest[T0[i]] = df;
        }else if(dist2 == longest[T0[i]] && df < shortest[T0[i]]){
            shortest[T0[i]] = df;
        }
    }

    for(int i=0;i<2;i++){
        if(longest[i] == -1){
            puts("-1 -1");
        }else{
            printf("%.6f %.6f\n", std::sqrt(longest[i]), 1. * shortest[i] / 60);
        }
    }

}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
int a[200005];
map<ll, ll> cnt1, cnt2;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    cnt1[i + a[i]]++, cnt2[(i - a[i])]++;
  }
  ll ans = 0;
  // for (pair<ll, ll> i : cnt2) {
  //   cout << i.ff << ' ' << i.ss << endl;
  // }
  // for (pair<ll, ll> i : cnt1) {
  //   cout << i.ff << ' ' << i.ss << endl;
  //   if (cnt2.find(i.ff) != cnt2.end())
  //     ans += cnt2[(i.ff)];
  // }
  for (pair<ll, ll> i : cnt2) {
    // cout << i.ff << ' ' << i.ss << endl;
    //
    if (cnt1.find(i.ff) != cnt1.end())
      ans += i.ss * cnt1[(i.ff)];
  }
  cout << ans << endl;
}

Measured memory_bytes: 27428
#include<stdio.h>
#include<stdlib.h>
int u[100005], v[100005], w[100005];
int ascu(const void* a, const void* b)
{
	if (u[*(int*)a] > u[*(int*)b])return 1;
	if (u[*(int*)a] < u[*(int*)b])return -1;
	return 0;
}
int ascv(const void* a, const void* b)
{
	if (v[*(int*)a] > v[*(int*)b])return 1;
	if (v[*(int*)a] < v[*(int*)b])return -1;
	return 0;
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n - 1; i++)
	{
		scanf("%d %d %d", &u[i], &v[i], &w[i]);
		u[i]--;
		v[i]--;
	}
	int ans[100005];
	for (i = 0; i < n; i++)
		ans[i] = 0;
	int l[100005];
	int m = 0;
	int c1[100005], c2[100005];
	for (i = 0; i < n - 1; i++)
		c1[i] = c2[i] = i;
	qsort(c1, n - 1, sizeof(int), ascu);
	qsort(c2, n - 1, sizeof(int), ascv);
	ans[0] = 1;
	i = 0;
	while (u[c1[i]] == 0)
	{
		if (w[c1[i]] % 2 == 0)
			ans[v[c1[i]]] = 1;
		else
			ans[v[c1[i]]] = 2;
		l[m] = v[c1[i]];
		m++;
		i++;
	}
	int min, max, mid, x;
	while (m >= 0)
	{
		m--;
		x = l[m];
		min = 0;
		max = n - 1;
		if (u[c1[min]] != x)
		{
			while (max - min > 1)
			{
				mid = (max + min) / 2;
				if (u[c1[mid]] < x)
					min = mid;
				else
					max = mid;
			}
			min++;
		}
		while (min < n - 1 && u[c1[min]] == x)
		{
			if (ans[v[c1[min]]] == 0)
			{
				l[m] = v[c1[min]];
				m++;
			}
			if (ans[x] == 1)
			{
				if (w[c1[min]] % 2 == 0)
					ans[v[c1[min]]] = 1;
				else
					ans[v[c1[min]]] = 2;
			}
			else
			{
				if (w[c1[min]] % 2 == 0)
					ans[v[c1[min]]] = 2;
				else
					ans[v[c1[min]]] = 1;
			}
			min++;
		}
		min = 0;
		max = n - 1;
		if (v[c2[min]] != x)
		{
			while (max - min > 1)
			{
				mid = (max + min) / 2;
				if (v[c2[mid]] < x)
					min = mid;
				else
					max = mid;
			}
			min++;
		}
		while (min < n - 1 && v[c2[min]] == x)
		{
			if (ans[u[c2[min]]] == 0)
			{
				l[m] = u[c2[min]];
				m++;
			}
			if (ans[x] == 1)
			{
				if (w[c2[min]] % 2 == 0)
					ans[u[c2[min]]] = 1;
				else
					ans[u[c2[min]]] = 2;
			}
			else
			{
				if (w[c2[min]] % 2 == 0)
					ans[u[c2[min]]] = 2;
				else
					ans[u[c2[min]]] = 1;
			}
			min++;
		}
	}
	for (i = 0; i < n; i++)
		printf("%d\n", ans[i] - 1);
	return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
int main()
{
ios_base::sync_with_stdio(false);
int a,b;
cin>>a>>b;
int x=b-a;
--x;
cout<<x*(x+1)/2-a;
}

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

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

int main(){
    int N,K; cin >> N >> K;
    vector<ll> num(K,0);
    //Kで割ってx余る数が何個あるか
    //->これを数えることでNすべてを探索しなくても良くなる
    for(int i=1;i<=N;i++) num[i%K]++;
    ll ans=0;
    for(int i=0;i<K;i++){
        //a%Kがきまると残りが決まる
        //->a+b，a+cがKの倍数になる必要があるから
        int b = (K-i)%K;
        int c = (K-i)%K;
        if((b+c)%K!=0) continue; //b+cがKの倍数でなければその組み合わせは加算しない
        ans += num[i]*num[b]*num[c];
    }
    cout << ans << endl;
    return 0;
}


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

bool pal(int a)
{

    return true;
}



int main()
{
    int n,m,mn=0,mx;
    cin>>n>>m;
    mx=n+1;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        if(a>=mn)
            mn=a;
        if(b<=mx)
            mx=b;
    }
    if(mn>mx)
        cout<<0;
    else
        cout<<mx-mn+1;
    return 0;
}




Measured memory_bytes: 3556
#include<stdio.h>
#include<math.h>
int main(void)
{
	float n,two[12],n2;
	while(1){
		int sin[12]={0},i,j=0,p=0;
		for(i=7;i>-5;i--){
			two[j]=pow(2,i);
			j++;
		}
		scanf("%f",&n);
		if(n<0){
			break;
		}
		for(i=0;i<12;i++){
			if(n>=two[i]){
				sin[i]=1;
				n=n-two[i];
			}
			if(n==0){
				p=1;
				i=12;
			}
		}
		if(p==0){
			printf("NA");
		}
		else{
			for(i=0;i<12;i++){
				printf("%d",sin[i]);
				if(i==7){
					printf(".");
				}
			}
		}
		printf("\n");
	}
	return 0;
}

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, p; cin >> n >> p;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int odd = 0;
  for (int i = 0; i < n; i++) odd += a[i] % 2;
  long long res;
  if (odd) res = 1LL << n - 1;
  else if (p) res = 0;
  else res = 1LL << n;
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define fore(e, u, v) for (int p = e(u), v = e[p].y; p; v = e[p = e[p].nxt].y)
#define forea(it, v) for (vector<int>::iterator it = (v).begin(); it != (v).end(); ++ it)
#define ri rd<int>
using namespace std;
const int maxN = 407;
const int INF = 1e9 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m;
bool occ[maxN];
int cnt[maxN][maxN];
bool vis[maxN], tag;
vector<int> q[maxN];

struct vec {
	static const int maxE = maxN * maxN * 2;
	int g[maxN], te;
	struct edge {int y, d, nxt;} e[maxE << 1];
	inline void push(int x, int y, int d) { e[++te] = (edge){y, d, g[x]}; g[x] = te; }
	inline void link(int x, int y, int d) { push(x, y, d), push(y, x, d); }
	inline int& operator () (int x) { return g[x]; }
	inline edge& operator [] (int x) { return e[x]; }
}e;

void dfs(int x, int d, vector<int> &q) {
	vis[x] = 1; q.push_back(x);
	fore (e, x, y) if (d > e[p].d) {
		if (!vis[y]) dfs(y, e[p].d, q);
		else tag = 1;
	}
}

int main() {

	n = ri(), m = ri();
	rep (i, 1, m) {
		int x = ri(), y = ri();
		if (x > y) swap(x, y);
		if (++ cnt[x][y] <= 2) e.link(x, y, i);
	}

	rep (i, 1, n) {
		occ[i] = 1;
		memset(vis, 0, sizeof vis); tag = 0;
		dfs(i, INF, q[i]);
		if (tag) occ[i] = 0;
	}

	int res = 0;
	rep (i, 1, n) if (occ[i])
	rep (j, i + 1, n) if (occ[j]) {
		memset(vis, 0, sizeof vis);
		forea (it, q[i]) vis[*it] = 1;
		bool ok = 1;
		forea (it, q[j]) if (vis[*it]) { ok = 0; break; }
		if (ok) ++ res;
	}

	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N=2e5+10;
LL n,a[N];
int main(){
	scanf("%lld",&n);
	for(LL i=1; i<=n; ++i)scanf("%lld",&a[i]);
	for(LL i=1; i<=n; ++i)if(a[i]>i-1||a[i]-a[i-1]>1)return puts("-1"),0;
	LL ans=0;
	for(LL i=n; i>=1; --i)
		if(a[i]+1!=a[i+1])ans+=a[i];
	printf("%lld",ans);
	return 0;
}

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

typedef long long ll;

int main () {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if ((A-1)/D >= (C-1)/B)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main()
{
    int arr[3][3], row, col, n, i, b, j=0;
    for(row=0; row<3; row++){
        scanf("%d %d %d", &arr[row][0], &arr[row][1], &arr[row][2]);
    }
    scanf("%d", &n);
    int r0=0, r2=0, r1=0, c0=0, c2=0, c1=0, d1=0, d2=0;
    for(i=0; i<n; i++){
        scanf("%d", &b);
        for(row=0; row<3; row++){
            for(col=0; col<3; col++){
                if(arr[row][col]==b){
                    if(row==0) r0++; 
                    else if(row==1) r1++;
                    else if(row==2) r2++;
                    if(col==0) c0++;
                    else if(col==1) c1++;
                    else if(col==2) c2++;
                    if(row==col) d1++;
                    if((row==2 && col == 0) || (row==0 && col==2) || (row==col)) d2++;
                }
                if(r0==3 || r2==3 || r1==3 || c0==3 || c2==3 || c1==3 || d1==3 || d2==3){
                    printf("Yes");
                    return 0;
                }
            }
        }
    }
    printf("No");
    return 0;
}

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

typedef long long int ll; 
#define MOD 1000000007
#define ON 200000
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(ll i=(a);i<(b);++i)
#define fn(i,a,b) for(ll i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define FF first
#define SS second
typedef pair<ll, ll> pll; 
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define MK make_pair
#define PB push_back
#define PO pop_back
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
///// This part below is only for debug, not used /////
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
///// END /////



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  rll(k);
  rll(n);
  vll v(n);
  cin >> v;

  ll ans = v[n-1]-v[0];

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

  return 0;
  
}

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

signed main() {
	int n;
	cin >> n;
	vector<pair<int, int>> a(n), b(n);
	rep(i, n) {
		cin >> a[i].first;
		a[i].second = i;
	}
	rep(i, n) {
		cin >> b[i].first;
		b[i].second = i;
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	vector<vector<pair<int, int>>> e(n);
	rep(i, n - 1) {
		e[a[i].second].push_back(make_pair(a[i + 1].second, a[i + 1].first - a[i].first));
		e[b[i].second].push_back(make_pair(b[i + 1].second, b[i + 1].first - b[i].first));
		e[a[i + 1].second].push_back(make_pair(a[i].second, a[i + 1].first - a[i].first));
		e[b[i + 1].second].push_back(make_pair(b[i].second, b[i + 1].first - b[i].first));
	}
	vector<int> now(n, inf);
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
	pq.push(make_pair(0, 0));
	while(!pq.empty()) {
		auto w = pq.top();
		pq.pop();
		if(now[w.second] > w.first) {
			now[w.second] = w.first;
			for(auto i: e[w.second]) {
				pq.push(make_pair(w.first + i.second, i.first));
			}
		}
	}
	rep(i, n) {
		cout << now[i] << endl;
	}
}


Measured memory_bytes: 21724
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
#define go(u) for (int o=ft[u],v;v=E[o].t,o;o=E[o].n)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> par;
typedef double dob;
template <typename t> inline bool chkmax(t &x,t y){return x<y?x=y,1:0;}
template <typename t> inline bool chkmin(t &x,t y){return x>y?x=y,1:0;}
const int N=100010;
int n,m,s,l,r,x[N];
LL p[N],ans;
int main(){
	scanf("%d%d",&n,&s);
	rep(i,1,n) scanf("%d%lld",x+i,p+i);
	int tp;
	for (tp=1;tp<=n;tp++) if (x[tp]>s) break;
	--tp;
	if (tp==0){
		printf("%d\n",x[n]-s);
		return 0;
	}
	if (tp==n){
		printf("%d\n",s-x[1]);
		return 0;
	}
//	rep(i,tp,n) y[i-tp+1]=x[i];
	l=1,r=n;
	ans+=x[r]-x[l];
	while (l<=tp&&r>tp){
		if (p[l]>=p[r]){
			while (r>tp){
				p[l]+=p[r];
				--r;
				if (p[r]>p[l]) break;
			}
			if (r==tp) ans+=s-x[l];
			else ans+=x[r]-x[l];
		} else {
			while (l<=tp){
				p[r]+=p[l];
				++l;
				if (p[r]<=p[l]) break;
			}
			if (l==tp+1) ans+=x[r]-s;
			else ans+=x[r]-x[l];
		}	
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = 1LL << 61;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, m, n, t, r, k, w, l, ans, i, j;
string S, T;
vl A, B, C, D(MAX_N, 1);
void solve() {
    n = S.length();
    rep(i, n) {
        if(S[i] == '0') {
            if(i % 2 == 0) {
                A.pb(i);
                B.pb(i * 2);
            } else {
                A.pb(i);
                C.pb(i * 2);
            }
        } else
            x++;
    }
    a = 0;
    b = A.size();
    rep(i, b) {
        if((A[i] + a) % 2 == 0) {
            if(a % 2 == 0) {
                ans += (n + 1) / 2 - (B.end() - lower_bound(all(B), 2 * A[i] - 1));
            } else {
                ans += (n + 1) / 2 - (C.end() - lower_bound(all(C), 2 * A[i] - 1));
            }
            D[i] = 1;
            a++;
            n--;
        }
    }

    /*debug(A);
    cout << endl;
    debug(B);
    cout << endl;
    debug(C);
    cout << endl;*/

    // cout << ans << " " << n << endl;

    if(n % 2 == 1)
        ans += (n + 1) * (n + 1) / 4;
    else
        ans += n * (n + 2) / 4;

    cout << ans << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S;
    solve();
}

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

int main()
{
  string s;
  cin>>s;
  
  int res=0;
 for(int i=0;i<s.length();i++)
  {
      res+=s[i]- '0';
  }
  if(res%9==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}

Measured memory_bytes: 3720