akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	double x[n],y[n],ans=0;
	for (int i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	for (int i=0;i<n-1;i++){
		for (int j=i+1;j<n;j++){
			ans+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		}
	}
	ans=ans*(n-1)/(n*(n-1)/2);
	printf("%.10lf",ans);
}

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

using pp=pair<int,int>;

int main() {
  int N;
  cin >> N;
  string ans="No";
  for (int i=0; i<=N/4; i++) {
    for (int j=0; j<=N/7; j++) {
      if (N==i*4+j*7) {
        ans = "Yes";
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
N = int(input())
dic = [0]*128
for _ in range(N): dic[ord(input()[0])] += 1
M,A,R,C,H = [dic[ord(x)] for x in list('MARCH')]
print(M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + M*C*H + A*R*C + A*R*H + A*C*H + R*C*H)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder_171B
{
    class Program
    {
        static void Main(string[] args)
        {
            var sum = Console.ReadLine();
            var price = Console.ReadLine();
 
            var productsum = sum.Split(' ').Select(s => int.Parse(s)).ToArray();
            var productprice = price.Split(' ').Select(t => int.Parse(t)).ToArray();

            //var productprice = new List<int> ();

            Array.Sort(productprice);

           //foreach (var i in productprice)            {
                //Console.WriteLine(i);
            //}

            int cost = 0;

            for( int j= 0;j<productsum[1]; ++j)
            {
                 cost = cost + productprice[j];
            }

            Console.WriteLine(cost);

 //           Console.ReadKey();

        }
    }
}


Measured memory_bytes: 28336
import sys
c_ls = []
for i in range(3):
    c = [int(i) for i in sys.stdin.readline().split()]
    c_ls.append(c)

yoko = [c_ls[0][i+1] - c_ls[0][i] for i in range(2)]
flg = True
for i in range(3):
    flg &= yoko == [c_ls[i][j+1] - c_ls[i][j] for j in range(2)]
print("Yes" if flg else "No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    int ct_4 = 0; 
    int ct_2 = 0;
    rep(i,n) {
        int a; cin >> a;
        if (a % 4 == 0) ct_4++;
        else if (a % 2 == 0) ct_2++;
    }
    if (ct_2 != 0) n -= ct_2-1;
    if ((2*ct_4 + 1) >= n) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
public class
Main
{
  public void
  run (
    )
  {
    java.util.Scanner sc = new java.util.Scanner ( System.in );
    int i, j;
    
    for ( ; ; )
    {
      java.util.Set<Pair> lis = new java.util.TreeSet<Pair> ( );
      int n, h;
      
      n = sc.nextInt ( );
      h = sc.nextInt ( );
      if ( n == 0 && h == 0 )
        break ;
      
      for ( i = 0; i < h; ++i )
      {
        String rw;
        int a, b;
        
        rw = sc.next ( );
        a = sc.nextInt ( );
        b = sc.nextInt ( );
        
        if ( rw.equals ( "xy" ) )
        {
          for ( j = 1; j <= n; ++j )
            lis.add ( new Pair ( a, b, j ) );
        }
        else if ( rw.equals ( "xz" ) )
        {
          for ( j = 1; j <= n; ++j )
            lis.add ( new Pair ( a, j, b ) );
        }
        else
        {
          for ( j = 1; j <= n; ++j )
            lis.add ( new Pair ( j, a, b ) );
        }
      }
      
      System.out.println ( n * n * n - lis.size ( ) );
    }
  
    return ;
  }

  public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( );
  
    return ;
  }
  
  private class
  Pair implements Comparable<Pair>
  {
    private int a;
    private int b;
    private int c;
    
    Pair (
      int a,
      int b,
      int c
      )
    {
      this.a = a;
      this.b = b;
      this.c = c;
      
      return ;
    }
    
    public int
    compareTo (
      Pair p
      )
    {
      if ( a - p.a != 0 )
        return ( a - p.a );
      if ( b - p.b != 0 )
        return ( b - p.b );
        
      return ( c - p.c );
    }
  }
}

Measured memory_bytes: 58468
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, x;
	while (cin >> n >> x, n) {
		int ans = 0;
		FOR(i, 1, n + 1)FOR(j, i + 1, n + 1)FOR(k, j + 1, n + 1) {
			if (i + j + k == x)ans++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3100
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

template<typename T1,typename T2>
std::ostream& operator<< (std::ostream& os,std::pair<T1,T2> pa){return os<<"["<<pa.first<<", "<<pa.second<<"]";}

template<typename T>
std::ostream& operator<< (std::ostream& os,std::vector<T> vec){
  os<<"{";
  for(int i=0;i<vec.size();i++)os<<vec[i]<<(i+1 == vec.size()?"":", ");
  os<<"}";
  return os;
}

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;

  if(n%2){
    std::cout<<n*(n-1)/2-n/2<<"\n";
    rep(i,1,n){
      rep(j,i+1,n+1){
        if(i+j!=n)std::cout<<i<<" "<<j<<"\n";
      }
    }
  }else{
    std::cout<<n*(n-1)/2-n/2<<"\n";
    rep(i,1,n){
      rep(j,i+1,n+1){
        if(i+j!=n+1)std::cout<<i<<" "<<j<<"\n";
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()





int main(){

  
  string s;
  cin>>s;
  int n=int(s.size());
  
  vi rl;
  vi lr;
  vi answers(n);
  lr.push_back(-1);
  
  for (int i=0;i<n-1;i++){
    if (s.at(i)=='R' and s.at(i+1)=='L'){
      rl.push_back(i);
    }
    else if (s.at(i)=='L' and s.at(i+1)=='R'){
      lr.push_back(i);
    }
  }

  lr.push_back(n-1);
  
  
  
  
  for (int i:rl){
    int rightlength,leftlength;
    rightlength=*upper_bound(ALL(lr),i)-i;
    leftlength=i-*(upper_bound(ALL(lr),i)-1);
    
    if ((rightlength+leftlength)%2==0){
      answers.at(i)=(rightlength+leftlength)/2;
      answers.at(i+1)=(rightlength+leftlength)/2;
    }
    else if (leftlength%2==1){
      answers.at(i+1)=(rightlength+leftlength)/2;
      answers.at(i)=answers.at(i+1)+1;
    }
    else {
      answers.at(i)=(rightlength+leftlength)/2;
      answers.at(i+1)=answers.at(i)+1;
    }
  }
  
  rep(i,n){
    cout<<answers.at(i)<<" ";
  }
  cout<<endl;
  


}












Measured memory_bytes: 1532
#include <iostream>
#include <string>
#include <vector>
#define NMAX (int)1e6

using namespace std;

int rev = 0;
//reverse
void Rev(){
	rev++;
}


int main(){
	vector<char> v,front;
	int Q,F[NMAX];
	char C[NMAX];
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); ++i)
	{
		v.push_back(S[i]);
	}
	cin >> Q;
	for (int i = 0; i < Q; ++i)
	{
		int T;
		cin >> T;
		if(T == 1){
			Rev();
		}else{
			cin >> F[i] >> C[i];
			if((F[i] == 1 && rev%2 == 1) || (F[i] == 2 && rev%2 == 0)){
				v.push_back(C[i]);
			}else{
				front.push_back(C[i]);
			}
		}
	}
	if(rev%2 == 1){
		for (int i = 0; i < v.size(); ++i)
		{
			cout << v[v.size()-i-1];
		}
		for (int i = 0; i < front.size(); ++i)
		{
			cout << front[i];
		}
		cout << endl;
	}else{
		for (int i = 0; i < front.size(); ++i)
		{
			cout << front[front.size()-i-1];
		}
		for (int i = 0; i < v.size(); ++i)
		{
			cout << v[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 5884
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a>0)printf("Positive\n");
  else if(b>0)printf("Zero\n");
  else if((b-a)%2)printf("Positive\n");
  else printf("Negative\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) {
    if (a < b)
    {
        return b;
    }
    return a; 
}

template<class T>
bool chmin(T &a, const T &b) {
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0; 
}

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

    if (a == 0)
    { 
        cout << 1 << endl;
    }
    if (b == 0)
    { 
        cout << 2 << endl;
    }
    if (c == 0)
    { 
        cout << 3 << endl;
    }
    if (d == 0)
    { 
        cout << 4 << endl;
    }
    if (e == 0)
    { 
        cout << 5 << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
s = input()
if len(s) % 2 == 1:
  print('No')
  exit()
for i in range(len(s)//2):
  #print(s[2*i:2*i+2])
  if s[2*i:2*i+2] != 'hi':
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,s=0;
	cin>>n;
	int a[n+1];
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		while(a[i]%2==0)
		{
			a[i]/=2;
			s++;
		}
	}
	cout<<s;
	return 0;
}

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

int main()
{
    int a,b,mx=INT_MIN;
    cin>>a>>b;
    if(mx<a+b)mx=a+b;
    if(mx<a-b)mx=a-b;
    if(mx<a*b)mx=a*b;
    cout<<mx<<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)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }

        
  int main(){
      string s,s1;
      cin>>s;
      rep(i,s.size()){
          if(s[i]!='x') s1+=s[i];
      }
    bool isp=true;
    lint ans=0;
    rep(i,s1.size()/2){
            if(s1[i]!=s1[s1.size()-1-i])isp=false;
    }
    if(!isp)cout<<-1;
    else {
        rep(i,s.size()/2){
                if(s[i]==s[s.size()-1-i])continue;
                else if(s[i]=='x'&&s[s.size()-1-i]!='x')s.insert(s.size()-i,"x");
                else if(s[s.size()-1-i]=='x'&&s[i]!='x')s.insert(i,"x");
                ans++;
        }
        cout<<ans;
    }
     }
  

  
     
  

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define submitStage int TCF = 1 ;
#define testStage int TCF = 1000 ;
#define Start while(TCF--)

void FastInputOutput(){
  ios_base :: sync_with_stdio( 0 ) ;
  cin.tie( 0 ) ;
  cout.tie( 0 ) ;
}
void ReadFromFile(){
  freopen( "in.txt", "r" , stdin ) ;
}
int D(){
	int t ;
	scanf( "%d" , &t ) ;
	return t ;
}
ll LLD(){
	ll t ;
	scanf( "%lld" , &t ) ;
	return t ;
}

const int N=1e6+7;
void init(){
}

int main(){
submitStage Start{
  int n=D(); int m=D();
  int mn=N+N+N;
  int mni=N+N+N;
  for(int i=m; i<n+m ; ++i){
    if(mn> abs(i)){
      mn=abs(i);
      mni=i;
    }
  }
  int sum=0;
  //cerr<<"&"<<mn<<endl;
  for(int i=m; i<n+m ; ++i){
    if(i==mni) continue;
    //cerr<<i<<" ";
    sum+=i;
  }
  printf("%d\n",sum);
}}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#define rr register
using namespace std;
const int d[10]={6,2,5,5,4,5,6,3,7,6};
int m,n,x[10],f[10011];
inline signed iut(){
	rr int ans=0; rr char c=getchar();
	while (!isdigit(c)) c=getchar();
	while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
	return ans;
}
inline signed max(int a,int b){return a>b?a:b;}
signed main(){
	m=iut(),n=iut(),memset(f,0xcf,sizeof(f));
	for (rr int i=1;i<=n;++i) x[i]=iut();
	sort(x+1,x+1+n),reverse(x+1,x+1+n),f[0]=0;
	for (rr int i=1;i<=n;++i)
	for (rr int j=d[x[i]];j<=m;++j)
	    f[j]=max(f[j],f[j-d[x[i]]]+1);
	while (m){
		for (rr int i=1;i<=n;++i)
		if (m>=d[x[i]]&&f[m]==f[m-d[x[i]]]+1){
			putchar(x[i]+48),m-=d[x[i]];
			break;
		}
	}
	return !putchar(10);
}

Measured memory_bytes: 1528
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char c[10010];
int n;
int main()
{
	gets(c);
	
	for(int i=1;i<strlen(c)-1;i++)
	  n++;
	cout<<c[0]<<n<<c[strlen(c)-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include <iosfwd>
#include<limits.h>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <limits>
#include<stdio.h>
#include <queue>
#include <stack>
#include <math.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include<vector>
#include <chrono>
#include <random>
using namespace std;
using namespace std::chrono;
#define fr(i,j,n)   for(lli i=j;i<(n);++i)
#define bk(i,j,n)   for(lli i=j;i>=n;--i)
#define pb push_back
#define m_p make_pair
#define Fs first
#define Sc second
#define endl "\n"
#define MOD 1000000007
#define present(c,x)    ((c).find(x) != (c).end())
#define count1 __builtin_popcount
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define mem(p,v) memset(p,(lli)v,sizeof p);
#define ub upper_bound
#define lb lower_bound
typedef long long int lli;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<lli> vl;
typedef pair<lli,lli> pl;
inline lli max(lli a,lli b){ return a>b?a:b;}
inline lli min(lli a,lli b){ return a<b?a:b;}
void show(vector<lli> v)
{
    fr(i,0,v.size())
    cout<<v[i]<<" ";
    cout<<endl;
}
void show(vector<int> v)
{
    fr(i,0,v.size())
    cout<<v[i]<<" ";
    cout<<endl;
}
void show(int a[], int arraysize)
{
    for (int i = 0; i < arraysize; ++i)
        cout << a[i] << " ";
    cout<<endl;
}
void show(lli a[], lli arraysize)
{
    for (lli i = 0; i < arraysize; ++i)
        cout << a[i] << " ";
    cout<<endl;
}
void show(unordered_set<int> s)
{
    for (auto it = s.begin(); it != s.end(); it++)
    {
        cout << *it << " ";
    }
    cout<<endl;
}
void show(unordered_map<int,int> mp)
{
    for (auto it = mp.begin(); it != mp.end(); it++)
    {
        cout << it->first << " "<<it->second<<endl;
    }
    cout<<endl;
}


int main()
{
    lli t,n,k,ans;
    t=1;
    while(t)
    {
        lli x;
        cin>>x>>n;
        lli a[n];
        fr(i,0,n)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        lli d=0,ans;
        while(d+x<INT_MAX&&x-d>INT_MIN)
        {
            lli ind=lower_bound(a, a+n, x-d)-a;
            if(a[ind]!=x-d)
            {
                ans=x-d;
                break;
            }
             ind=lower_bound(a, a+n, d+x)-a;
            if(a[ind]!=x+d)
            {
                ans=x+d;
                break;
            }
            d++;
        }
        cout<<ans<<endl;
        t--;
    }
    return 0;
}



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

using namespace std;

int main(int argc, char **argv) {
    int n;
    int res = 500000000;
    vector<int> a;

    cin >> n;
    a.resize(n);
    for (auto&& i : a) {
        cin >> i;
    }

    for (auto&& i : a) {
        int count = 0;
        while(i % 2 ==0) {
            i /= 2;
            count++;
        }

        if (res > count) {
            res = count;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int gcd(int a, int b){ return b?gcd(b, a%b):a; }
const int M=1e6+1;
vector<int> sieve(int n){
  vector<int> res(n); iota(res.begin(), res.end(), 0);
  for(int i=2; i*i<n; ++i){
    if (res[i] < i) continue;
    for (int j = i*i; j < n; j += i)
      if (res[j] == j) res[j] = i;
  }
  return res;
}

vector<int> factor(int n, const vector<int>& min_factor) {
  vector<int> res;
  while (n > 1) {
    int p=min_factor[n];
    res.push_back(p);
    while(n%p==0){ n/=p; }
  }
  return res;
}

int main(){
int N, ans=0; cin >> N; int c=0, A[N+1]={};
REP(i, N){ cin >> A[i]; c=gcd(A[i], c); }
if(c>=2){ cout << "not coprime\n"; return 0; }
  
vector<int> min_factor=sieve(M);
int ksht[M]={};
REP(i, N){ 
  vector<int> fac=factor(A[i], min_factor);
  REP(j, fac.size()){ 
    if(ksht[fac[j]]){ cout << "setwise coprime\n"; return 0; }
    else{ ksht[fac[j]]=1; } 
  }
}
cout << "pairwise coprime\n";
}

Measured memory_bytes: 14712
n=int(input())
a=[int(j)for j in input().split()]
ans=0
s=sum(a)
p=1
b=True
for i,j in enumerate(a):
    if p<j:
        print(-1)
        exit()
    ans+=p
    p-=j
    s-=j
    if i==n:
        continue
    if p<s and b:
        if p*2<s:
            p*=2
        else:
            p=s
    if p==s:
        b=False
print(ans)

Measured memory_bytes: 85612
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr, sort)
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  xs <- mergeSort . U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let (ys,zs) = U.splitAt (n `quot` 2) xs
      y = U.last ys
      z = U.head zs
  print $ z - y

mergeSortBy :: (U.Unbox a) => (a -> a -> Ordering) -> U.Vector a -> U.Vector a
mergeSortBy !cmp !vec = doSort vec
  where
    doSort vec | U.length vec <= 1 = vec
               | otherwise = let (xs, ys) = U.splitAt (U.length vec `quot` 2) vec
                             in merge (doSort xs) (doSort ys)
    merge xs ys = U.create $ do
      let !n = U.length xs
          !m = U.length ys
      result <- UM.new (n + m)
      let loop !i !j
            | i == n = U.copy (UM.drop (i + j) result) (U.drop j ys)
            | j == m = U.copy (UM.drop (i + j) result) (U.drop i xs)
            | otherwise = let !x = xs U.! i
                              !y = ys U.! j
                          in case cmp x y of
                               LT -> do UM.write result (i + j) x
                                        loop (i + 1) j
                               EQ -> do UM.write result (i + j) x
                                        UM.write result (i + j + 1) y
                                        loop (i + 1) (j + 1)
                               GT -> do UM.write result (i + j) y
                                        loop i (j + 1)
      loop 0 0
      return result

mergeSort :: (U.Unbox a, Ord a) => U.Vector a -> U.Vector a
mergeSort = mergeSortBy compare


Measured memory_bytes: 5116
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int[] dice=new int[6];
		int[] nwse={1,5,4,2,3};
		String[] str=br.readLine().split(" ");//diceの配列に面の値を読み込む
		for(int i=0;i<6;i++){
			dice[i]=Integer.parseInt(str[i]);
		}
		String a=br.readLine();
		char dis[]=a.toCharArray();//読み込んだ方角推移をchar型のdis[]に格納
		for(int i=0;i<a.length();i++){
			nwse=rolling(dis[i],nwse);
		}
		System.out.println(dice[nwse[0]-1]);
	}
		
		
	public static int[] rolling(char b,int nwse[]){
			int p=0,q=0;
			switch (b){
			case 'S':
				{p=3;q=1;break;}
			case 'W':
				{p=2;q=4;break;}
			case 'N':
				{p=1;q=3;break;}
			case 'E':
				{p=4;q=2;break;}
			default:
					System.out.println("その方角は受け入れられません");
			}
			nwse[p]=nwse[0];nwse[0]=nwse[q];nwse[q]=7-nwse[p];
			return nwse;
	}
}

Measured memory_bytes: 17040
#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    
    int i,j,x;
    int count = 0;
    
    char str[202];
    char fstr[101];
    
    scanf("%s",str);
    
    scanf("%s",fstr);
    
    int len = strlen(str);
    int flen = strlen(fstr);
    
    for (i = len; i < len+len; i++) {
        str[i] = str[i-len];
    }
    
    for (i = 0; i < len+len; i++) {
        if (str[i] == fstr[0]) {
            for (j = 0; j < flen; j++) {
                if (str[i+j] != fstr[j]) {
                    break;
                }
            }
            
            if (j == flen) {
                printf("Yes\n");
                return 0;
            }
        }
    }
    
    printf("No\n");
    
    return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    long long N, D[200001], i,  M, T[200001], num=1, judge=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> D[i];
    }

    cin >> M;

    for(i=1; i<=M; i++){
        cin >> T[i];
    }

    sort(D+1, D+N+1);

    sort(T+1, T+M+1);

    if(N >= M){
        for(i=1; i<=N; i++){
            if(D[i] == T[num]){
                num++;
            }

            if(num == M+1){
                judge = 1;

                break;
            }
        }

        if(judge == 1){
            cout << "YES" << endl;
        }

        else{
            cout << "NO" << endl;
        }
    }

    else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main() {
  ll n,x,l,sum=0,ans=1;
  cin >> n >> x;
  rep(i,n){
  	cin >>l; sum+=l;
  	if(sum<=x) ans++;
  	else break;
  }
  cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N, T; cin >> N >> T;
  if (N == 1) return;
  vi32 A(N); cin >> A;
  int mi = A[0], diff = 0, cnt = 0;
  reps(i, N - 1) {
    amin(mi, A[i]);
    if (A[i] - mi > diff) {
      diff = A[i] - mi;
      cnt = 1;
    } else if (A[i] - mi == diff) {
      cnt++;
    }
  }
  cout << cnt << '\n';
}


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

using namespace std;

#define ll long long

int main() {
  int n, W;
  scanf("%d %d", &n, &W);
  vector<ll> dp(W + 1);
  for (int item = 0; item  < n; ++item) {
    int weight, value;
    scanf("%d %d", &weight, &value);
    for (int weight_already = W - weight; weight_already >= 0; -- weight_already) {
      dp[weight_already + weight] = max(dp[weight_already + weight], dp[weight_already] + value);
    }
  }
  ll answer = 0;
  for (int i = 0; i <= W; ++i) {
    answer = max(answer, dp[i]);
  }
  printf("%lld\n", answer);
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		int y = saori.saori_hayami();
		int[] a = new int[] {-1,0,2,0,1,0,1,0,0,1,0,1,0};
		if(a[x] == a[y]){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 64000
#define MOD 1000000007
using namespace std;
using LL = long long;
int n,k,m;
int l[M],r[M],d[M];
LL dp[105][M], nxt[M];
map<int,int> mr;
int main()
{
    while (~scanf("%d %d", &n, &k)) {
        m = 0;
        mr.clear();
        for (int i=1; i<=n; ) {
            int j = n/(n/i);
        
            m++;
            l[m] = i;
            r[m] = j;
            d[m] = n/i;
            mr[j] = m;
            
            i = j+1;
        }

        REP(i,1,m) d[i] = mr[d[i]];

        //REP(i,1,m) printf("l=%d r=%d div=%d d=%d\n",l[i],r[i],n/l[i],d[i]);

        MSET(dp, 0);
        REP(i,1,m) dp[1][i] = r[i]-l[i]+1;
        REP(i,1,k-1) {
            MSET(nxt, 0);
            REP(j,1,m) nxt[d[j]] += dp[i][j];

            LL fr = 0;
            for (int j=m; j>=1; j--) {
                fr = (fr + nxt[j]) % MOD;
                dp[i+1][j] = fr * (r[j]-l[j]+1) % MOD;
            }
        }

        LL ans = 0;
        REP(i,1,m) ans = (ans + dp[k][i]) % MOD;
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 56960
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = ReadLine().Split('S').Max(a => a.Length);
		WriteLine(n);
	}
}


Measured memory_bytes: 18776
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

struct slime {
	int y;
	int x;
	bool wall;
};


struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main() {
	int N, W, H; cin >> N >> W >> H;
	vector<vector<int>>ws(W);
	vector<vector<int>>hs(H);
	bool hasi = false;
	for (int i = 0; i < N; ++i) {
		int x, y; cin >> x >> y;
		x--; y--;
		if (x == 0 || x == W - 1 || y == 0 || y == H - 1) {
			hasi = true;
		}
		ws[x].push_back(i);
		hs[y].push_back(i);
	}
	UnionFind uf(N);

	for (int i = 0; i < ws.size(); ++i) {
		for (int j = 1; j < ws[i].size(); ++j) {
			uf.unionSet(ws[i][j], ws[i][j - 1]);
		}
	}
	for (int i = 0; i < hs.size(); ++i) {
		for (int j = 1; j < hs[i].size(); ++j) {
			uf.unionSet(hs[i][j], hs[i][j - 1]);
		}
	}
	vector<bool>beroot(N, false);
	for (int i = 0; i < N; ++i) {
		beroot[uf.root(i)] = true;
	}
	int bunkai = count(beroot.begin(), beroot.end(), true);
	int ans;
	if (bunkai == 1) {
		ans = N - 1;
	}
	else {
		ans = N  + bunkai - 1 - hasi;
	}
	cout << ans << endl;
	return 0;
}

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

#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define TR(...)
#endif

typedef long long                LL;
typedef vector < int >           VI;
typedef pair < int,int >         II;
typedef vector < II >            VII;

#define MOD                      1000000007
#define EPS                      1e-12
#define N                        200100
#define PB                       push_back
#define MP                       make_pair
#define F                        first 
#define S                        second
#define ALL(v)                   v.begin(),v.end()
#define SZ(a)                    (int)a.size()
#define FILL(a,b)                memset(a,b,sizeof(a))
#define SI(n)                    scanf("%d",&n)
#define SLL(n)                   scanf("%lld",&n)
#define PLLN(n)                  printf("%lld\n",n)
#define PIN(n)                   printf("%d\n",n)
#define REP(i,j,n)               for(LL i=j;i<n;i++)
#define PER(i,j,n)               for(LL i=n-1;i>=j;i--)
#define endl                     '\n'
#define fast_io                  ios_base::sync_with_stdio(false);cin.tie(NULL)

#define FILEIO(name) \
  freopen(name".in", "r", stdin); \
  freopen(name".out", "w", stdout);
 
inline int mult(int a , int b) { LL x = a; x *= LL(b); if(x >= MOD) x %= MOD; return x; }
inline int add(int a , int b) { return a + b >= MOD ? a + b - MOD : a + b; }
inline int sub(int a , int b) { return a - b < 0 ? MOD - b + a : a - b; }
LL powmod(LL a,LL b) { if(b==0)return 1; LL x=powmod(a,b/2); LL y=(x*x)%MOD; if(b%2) return (a*y)%MOD; return y%MOD; }

map <int, int> mp;

int main() {
  int n; cin >> n;
  for(int i = 0; i < n; i ++) {
    int x; cin >> x;
    mp[x] ++;
  }
  LL a = -1, b = -1;
  for(auto it = mp.end(); ;) {
    it--;
    if(a==-1){
      if(it->S >= 4) {
        a = it->F;
        b = a;
        break;
      }
      else if(it->S >= 2){
        a = it->F;
      }
    }
    else {
      if(it->S >= 2) {
        b = it->F;
        break;
      }
    }
    if(it==mp.begin()) break;
  }
  if(a==-1 || b==-1) cout << 0 << endl;
  else cout << a*b << endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;

const ull ULL_MAX = 1.8446744e+19;

using namespace std;

int main() {

	int x, a;

	cin >> x >> a;

	int ans = x < a ? 0 : 10;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n, m;
    cin >> n >> m;
    Graph g (n);
    vector<int> chk (n, 0);
    rep (i, m) {
        int x, y;
        cin >> x >> y;
        g[x].push_back (y);
        chk[y]++;
    }
    queue<int> q;
    rep (i, n) if (chk[i] == 0) q.push (i);

    vector<int> sortedvec;
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (auto next : g[now]) {
            if (!chk[next]) continue;
            chk[next]--;
            if (!chk[next]) q.push (next);
        }
        sortedvec.push_back (now);
    }
    rep (i, n) cout << sortedvec[i] << "\n";
}


Measured memory_bytes: 3748
#include <queue>
#include <string>
#include <iostream>
using namespace std;
struct state {
	vector<vector<string> > v;
	int steps;
	int result;
};
int N, Q;
int main() {
	while (cin >> N >> Q, N | Q) {
		vector<vector<string>> v(N, vector<string>(2));
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 2; j++) cin >> v[i][j];
		}
		vector<vector<vector<string> > > w(Q, vector<vector<string> >(2, vector<string>(2)));
		for (int i = 0; i < Q; i++) {
			for (int j = 0; j < 2; j++) {
				for (int k = 0; k < 2; k++) cin >> w[i][j][k];
			}
			if (w[i][0] == vector<string>({ "..", ".." })) {
				w[i][0] = w[i][1];
				w[i][1] = vector<string>({ "..", ".." });
			}
		}
		queue<state> que; que.push(state{ v, 0, 0 });
		int ret = 0;
		while (!que.empty()) {
			state s1 = que.front(); que.pop();
			if (s1.steps == Q) {
				ret = max(ret, s1.result);
				continue;
			}
			vector<vector<int> > h1(2, vector<int>(2, -1));
			for (int i = 0; i < 2; i++) {
				for (int j = 0; j < 2; j++) {
					for (int k = 0; k < s1.v.size(); k++) {
						if (s1.v[k][i][j] == '#') h1[i][j] = k + 1;
					}
				}
			}
			for (int dy = -1; dy <= 1; dy++) {
				for (int dx = -1; dx <= 1; dx++) {
					bool ok = true;
					vector<vector<string> > v1(2, vector<string>(2, ".."));
					for (int i = 0; i < 2; i++) {
						for (int j = 0; j < 2; j++) {
							for (int k = 0; k < 2; k++) {
								int tx = k + dx, ty = j + dy;
								if (w[s1.steps][i][j][k] == '#') {
									if (0 <= tx && tx < 2 && 0 <= ty && ty < 2) v1[i][ty][tx] = '#';
									else ok = false;
								}
							}
						}
					}
					if (ok) {
						vector<vector<int> > h2(2, vector<int>(2, -1));
						for (int i = 0; i < 2; i++) {
							for (int j = 0; j < 2; j++) {
								for (int k = v1.size() - 1; k >= 0; k--) {
									if (v1[k][i][j] == '#') h2[i][j] = k;
								}
							}
						}
						int h3 = 0;
						for (int i = 0; i < 2; i++) {
							for (int j = 0; j < 2; j++) {
								if (h1[i][j] == -1 || h2[i][j] == -1) continue;
								h3 = max(h3, h1[i][j] - h2[i][j]);
							}
						}
						vector<vector<string> > v2 = s1.v; v2.resize(v2.size() + 2, vector<string>({ "..", ".." }));
						for (int i = 0; i < 2; i++) {
							for (int j = 0; j < 2; j++) {
								for (int k = 0; k < 2; k++) {
									if (v1[i][j][k] == '#') v2[h3 + i][j][k] = '#';
								}
							}
						}
						int cnt = 0;
						for (int i = v2.size() - 1; i >= 0; i--) {
							if (v2[i] == vector<string>({ "##", "##" })) v2.erase(v2.begin() + i), cnt++;
						}
						que.push(state{ v2, s1.steps + 1, s1.result + cnt });
					}
				}
			}
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <string>

int gcd(int x, int y) {
    if (y > x) {
        int t = x;
        x = y, y = t;
    }

    while (y) {
        int s = x % y;
        x = y;
        y = s;
    }

    return x;
}

int main() {
    int x, y;
    std::cin >> x >> y;
    std::cout << gcd(x, y) << std::endl;
}


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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
#define PRINT_ENTER() cout << endl;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    ll N, M;
    cin >> N >> M;
    ll left = 1, right = N;
    REP(i, M) {
        ll L, R;
        cin >> L >> R;
        left = max(left, L);
        right = min(right, R);
    }
    cout << max(right - left + 1, 0LL) << endl;
    return 0;
}

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


using namespace std;


void atcoder_beginner_contest999()
{
  string n;
  cin >> n;

  for (int i = 0; i < n.size(); ++i)
  {
    if (n[i] == '1') n[i] = '9';
    else if (n[i] == '9') n[i] = '1';
  }
  cout << n << "\n";
}


void programming_education()
{
  int n;
  cin >> n;
  
  if (n == 1)
  {
    cout << "Hello World\n";
    return;
  }
  else
  {
    int a, b;
    cin >> a >> b;
    cout << a + b << "\n";
  }
}

void discount_fare()
{
  int x, y;
  cin >> x >> y;

  cout << x + y / 2 << "\n";
}


int main()
{
  //atcoder_beginner_contest999();
  //programming_education();
  discount_fare();
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int NMAX = 100005;
int n, k, q;
int v[NMAX];

int main()
{
	cin >> n >> k >> q;
	for (int i = 1;i <= q;++i)
	{
		int x;
		cin >> x;
		++v[x];
	}
	for (int i = 1;i <= n;++i)
	{
		v[i] = k - (q - v[i]);
		if (v[i] > 0)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 1024
_=input()
q=input()
ans=min(q[1:].count("E"),q[:-1].count("W"))
left=0
right = q.count("E")
for i in q:
	if i=="E":
		right-=1
	else:
		left+=1
	ans=min(ans,right+(left!=0)*left)
print(ans)

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int main() {
 int a;
  int count = 0;
  cin >> a;
  for(int i=0;i<26;i++){
   for(int j=0;j<15;j++){
     int total = i*4 + j*7;
     if(total==a){
       count++;
       break;
     }
     if(total>101){
      break;
     }
   }
  }
  if(count==0){
  cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	class UnionFind {
		private int[] par, rank;
		UnionFind(int n) {
			par = new int[n];
			rank = new int[n];
			for (int i = 0; i < n; i++)
				par[i] = i;
		}
		int find(int x) {
			if (par[x] == x)
				return x;
			else
				return par[x] = find(par[x]);
		}
		void unite(int x, int y) {
			x = find(x);
			y = find(y);
			if (x == y)
				return;
			if (rank[x] < rank[y]) {
				par[x] = y;
			} else {
				par[y] = x;
				if (rank[x] == rank[y])
					rank[x]++;
			}
		}
		boolean same(int x, int y) {
			return find(x) == find(y);
		}
	}
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		UnionFind uf = new UnionFind(n);
		for (int i = 0; i < m; i++) {
			int s = scan.nextInt();
			int t = scan.nextInt();
			uf.unite(s, t);
		}

		int q = scan.nextInt();
		for (int i = 0; i < q; i++) {
			int s = scan.nextInt();
			int t = scan.nextInt();
			System.out.println(uf.same(s, t) ? "yes" : "no");
		}

	}
	public static void main(String[] args) {
		new Main().run();
	}
}



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

int main(){
  int A,B;
  cin >> A >> B;

  int price8=ceil(A * 100.0 / 8);
  int price10=B * 10;
  vector<int> v8,v10;
  while(price8 * 8 / 100 == A){
    v8.push_back(price8++);
  }
  while(price10 / 10 == B){
    v10.push_back(price10++);
  }

  for (int x : v8){
    for (int y : v10){
      if (x == y){
        cout << x;
        return 0;
      }
    }
  }
  cout << -1;
  return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	string t = s;
	reverse(all(t));
	cout << (s == t ? "Yes" : "No") << endl;
	return 0;
}

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

using namespace std;

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

typedef long long LL;

LL cnt[100000];
int n, m, p[100000];

int main() {
	cin >> n >> m;
	REP(i, m) scanf("%d", &p[i]);

	FOR(i, 1, m) {
		int a = min(p[i - 1], p[i]) - 1, b = max(p[i - 1], p[i]) - 1;
		cnt[a] += 1; cnt[b] -= 1;
	}
	FOR(i, 1, n) cnt[i] += cnt[i - 1];

	LL total = 0;
	REP(i, n - 1) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		LL ans = min(a*cnt[i], b*cnt[i] + c);
		total += ans;
	}

	cout << total << endl;
	return 0;
}

Measured memory_bytes: 2412
#include <stdio.h>
 
int main(void) {
    double a,b,c,d,e,f;
    double x,y;
    while(!feof(stdin)) {
        scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f);
        if(feof(stdin))break;
        x=(c*e-f*b)/(a*e-d*b);
        y=(c*d-f*a)/(b*d-e*a);
        if(x>-0.001 && x<0.001)x=0;
        if(y>-0.001 && y<0.001)y=0;
        printf("%1.3f %1.3f\n",x,y);
    }
    return 0;
}

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

int main(){
    int c[3][3];
    int x[3], y[3];
    bool flag = true;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    for(int i = 0; i < 3; i++){
        y[i] = c[0][i] - x[0];
    }
    for(int i = 0; i < 3; i++){
        x[i] = c[i][0] - y[0];
    }

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(x[i] + y[j] != c[i][j]) flag = false;
        }
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
s = input()
ans = 1e9
for alpha in "abcdefghijklmnopqrstuvwxyz":
    cur = list(s)
    cnt = 0
    while len(set(cur))>1:
        # print(alpha, cnt, cur)
        for i in range(1,len(cur)):
            if cur[i]==alpha:
                cur[i-1]=alpha
        cur.pop()
        cnt += 1
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
  	ll x,a;cin>>x>>a;
  	cout << (x<a?0:10) << ednl;
}


Measured memory_bytes: 256