akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        List<int> b = Console.ReadLine().Split().Select(int.Parse).ToList();
        List<int> a = solve(b,n);
        foreach(int i in a) Console.WriteLine(i);
    }
    static List<int> solve(List<int> b, int n) {
        List<int> a = new List<int>();
        for (int i = n; i >= 1; i --) {
            if (b[i-1]>i) {
                    a.Clear();
                    a.Add(-1);
                    return a;
                }
            for (int j = i-1; j >= 0; j --) {
                if (b[j]==j+1) {
                    a.Add(b[j]);
                    b.RemoveAt(j);
                    break;
                }
            }
        }
        a.Reverse();
        return a;
    }
}

Measured memory_bytes: 13268
/*
#include<rabbit>;
using blueHulkStress;
using AceOfSpades;
*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
const int dx[] = {1,-1,0,0,1,-1,1,-1};
const int dy[] = {0,0,1,-1,1,-1,-1,1};
const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};

ll n, k;

ll dp[1002][1002];

int main(int argc, char const *argv[])
{
	
	cin>>n>>k;

	for (int i = 0; i < k; ++i)
	{
		dp[0][i] = 1;
	}

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < k; ++j)
		{
			for(int t = 0; t < k; t++)
			{
				if(t == j)
				 	continue;
				if(i)
					dp[i][j]+=dp[i-1][t];
			} 
		}
	}
	ll ans = 0;

	rep(i,k)ans+=dp[n-1][i];

	cout<<ans;
}	

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
int Inf=(1<<30);
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  int ans=Inf;
  int sum2=0;
  for(int i=0;i<n;i++){
    ans=min(ans,abs(sum-sum2));
    sum-=a[i];
    sum2+=a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 896
M = [100,101,102,103,104,105]
X = int(input())

dp = [0 for i in range(X+1)]
dp[0] = 1

for i in range(X):
    if dp[i] == 1:
        for j in M:
            if i + j <= X:
                dp[i+j] = 1
print(dp[-1]) 

Measured memory_bytes: 3864
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double area = r * r * Math.PI;
		double circumference = 2 * r * Math.PI;
		System.out.printf("%f ", area);
		System.out.printf("%f%n", circumference);
		sc.close();
	}
}


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

int main()
{
	set<int> a;
	for (int d = 1; d <= 30; d++)
	{
		a.insert(d);
	}
	for (int b = 0; b < 28; b++)
	{
		int c;
		cin >> c;
		a.erase(c);
	}
	set<int>::iterator it = a.begin();
	for (int g = 0; g < 2; g++)
	{
		cout << *it << endl;
		it++;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>

const int INF = 10e6;

char maze[60][60];
int dist[60][60];
bool isReached = false;
int dx[4] = {1, -1 ,0 ,0};
int dy[4] = {0, 0, 1, -1};

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main() {
    int h, w;
    int defaultWhite = 0;
    cin >> h >> w;
    rep(i, h) cin >> maze[i];
    rep(i, h) {
        for(int j = 0; j < w; j++) {
            if(maze[i][j] == '.') {
                defaultWhite += 1;
            }
            dist[i][j] = INF;
        }
    }

    queue<int> qx, qy;
    qx.push(0);
    qy.push(0);
    dist[0][0] = 1;
    while(qx.size() != 0) {
        int x = qx.front();
        int y = qy.front();
        qx.pop();
        qy.pop();
        for(int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
            if (dist[ny][nx] != INF || maze[ny][nx] == '#') continue;
            dist[ny][nx] = dist[y][x] + 1;
            qx.push(nx);
            qy.push(ny);
        }
    }

    if (dist[h-1][w-1] == INF) cout << -1 << endl;
    else {
        //cout << dist[h-1][w-1] << " " << defaultBlack << endl;
        int ans = defaultWhite - dist[h-1][w-1];
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=100050,mo=1e9+7;
using namespace std;
inline int gi(){
  char ch=getchar();int x=0,q=0;
  while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int fap(int a,int b){
  int s=1;
  while(b){
    if (b&1) s=1ll*s*a%mo;
    a=1ll*a*a%mo,b>>=1;
  }
  return s;
}
int ml[N],ny[N],bj[N],l,r;
int main(){
  int n=gi()+1,s;
  ml[0]=ny[0]=1;
  for (int i=1; i<=n; ++i){
    ml[i]=1ll*ml[i-1]*i%mo;
    s=gi();
    if (bj[s])
      l=bj[s],r=i;
    bj[s]=i;
  }
  --l,r=n-r,r+=l;
  ny[n]=fap(ml[n],mo-2);
  for (int i=n-1; i; --i)
    ny[i]=1ll*ny[i+1]*(i+1)%mo;
  int ans;
  for (int i=1; i<=n; ++i){
    ans=1ll*ml[n]*ny[i]%mo*ny[n-i]%mo;
    if (i-1<=r)
      ans-=1ll*ml[r]*ny[i-1]%mo*ny[r-i+1]%mo;
    printf("%d\n",(ans+mo)%mo);
  }
  return 0;
}


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

main()
{
	int n,k;
	cin>>n>>k;
	
	vector<int> v(n),dp(k+1);
	
	for(int i=0;i<n;i++)
	cin>>v[i];
	
	for(int i=1;i<=k;i++)
	{
		for(auto j:v)
		{
			if(j<=i && !dp[i-j])
			{
				dp[i]=1;
				break;
			}
		}
	}
	
	if(dp[k])
	cout<<"First";
	else
	cout<<"Second";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll arr[5];
    ll ans;
    for(ll i=0;i<5;i++)
    {
        cin>>arr[i];
        if(arr[i]==0)
        {
            cout<<i+1<<" ";
        }
    }
    return 0;
}

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

int main()
{
long long int t,i,s=0,s1=0;
cin>>t;
int v[1000];
int c[1000];
for(i=0;i<t;i++)
{
    cin>>v[i];
}
for(i=0;i<t;i++)
{
    cin>>c[i];
}
for(i=0;i<t;i++)
{
    if(v[i]>=c[i])
    {
        s=s+v[i];
       s1=s1+c[i];
    }
}
cout<<s-s1<<endl;

}


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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define ll  long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi      vector<int>
#define pii     pair<int,int>
#define piii    pair<pair<int,int>,int>
#define all(v)  v.begin(), v.end()

int mod = 1000000007;
const int N = 505;
vi v[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m,  q;
    cin >> n >> m >> q;
   // cout << log2(500) << endl;

    for (int i = 1; i <= m; i++)
    {
        int x, y;
        cin >> x >> y;
        v[x].pb(y);
    }
    for (int i = 1; i <= n; i ++)
    {
        if ( v[i].size() > 0)
           sort( v[i].begin(), v[i].end());
    }

    while( q-- )
    {
        int x, y;
        cin >> x>> y;
        int ans = 0;
        for (int i = x; i <= y; i ++)
        {
            int z = upper_bound(v[i].begin(), v[i].end(), y) - v[i].begin();
            ans += z;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
N,K,x[50],y[50];
i,l,r,u,d,k;
long long w,h,z=4.6e18;
main(){
	scanf("%d%d",&N,&K);
	for(i=0;~scanf("%d%d",x+i,y+i);++i);
	for(l=0;l<N;++l)for(r=0;r<N;++r)for(u=0;u<N;++u)for(d=0;d<N;++d){
		w=x[r]-x[l];
		h=y[d]-y[u];
		if(w>0&&h>0){
			k=0;
			for(i=0;i<N;++i){
				k+=x[l]<=x[i]&&x[i]<=x[r]&&y[u]<=y[i]&&y[i]<=y[d];
			}
			if(k>=K&&w*h<z){
				z=w*h;
			}
		}
	}
	printf("%lld",z);
}


Measured memory_bytes: 128
from collections import deque

N = int(input())

minDist = [[1 if s == '1' else float('inf') for s in input()] for _ in range(N)]

for i in range(N):
    minDist[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            if minDist[i][j] > minDist[i][k] + minDist[k][j]:
                minDist[i][j] = minDist[i][k] + minDist[k][j]

base = [d % 2 for d in minDist[0]]

for i in range(N):
    A = [0] * N
    for j, d in enumerate(minDist[i]):
        A[j] = (d + base[i]) % 2
    if A != base:
        print(-1)
        exit()

ans = max([max(D) for D in minDist]) + 1
print(ans)

Measured memory_bytes: 48160
#include <stdio.h>
int main(void){
    int n,ans =0;
        for(int a=0; a<9; a++){
            for(int b=0; b<9; b++){
                ans = (a+1)*(b+1);
                printf("%dx%d=%d\n",a+1,b+1,ans);
            }
        }
    return 0;
}



Measured memory_bytes: 2040
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		//System.out.println(N + "," + A);

		int balance = N % 500;

		if (balance <= A) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

int main() {
  string S;
  cin >> S;
  string ans = "No";
  if(S.at(2)==S.at(3) && S.at(4)==S.at(5)) ans = "Yes";
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef double ld;
#define MAX (1LL << 63LL) - 1LL
#define MIN (-1LL) * (1LL << 63LL) + 1LL

ll s;
ll pa[2010][2010];
ll ss = 1000000007;
ll sum;

int main(void)
{
	pa[0][0] = 1;
	
	for(ll i = 1 ; i < 2010 ; i++)
	{
		for(ll j = 0 ; j <= i ; j++)
		{
			if(j == 0)
				pa[i][j] = 1;
			else
				pa[i][j] = (pa[i - 1][j] + pa[i - 1][j - 1]) % ss;
		}
	}
	
	scanf("%lld", &s);
	
	for(ll i = 1 ; ; i++)
	{
		s -= 3;
		
		if(s < 0)
			break;
		
		sum = (sum + pa[s + i - 1][s]) % ss;
	}
	
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 26640
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        mut x: [u64; n],
    }
    let mut xx = x.clone();
    xx.sort();
    let h = xx[n / 2];
    let l = xx[n / 2 - 1];

    for x_ in x {
        println!("{}", if x_ <= l { h } else { l })
    }
}


Measured memory_bytes: 10364
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

vector<bool> genbit(ll a){
    vector<bool> r(50);
    for(int i = 0; i < 50; i++){
        r[i] = (a  & (1ll << i));
    }
    return r;
}

ll memo[50][2]; //上位a + 1桁,　なおbは未満フラグ
void init(){
    for (int a = 0; a < 50; ++a) {
        for (int b = 0; b < 2; ++b) {
            memo[a][b] = 0;
        }
    }
}

int main() {
    init();
    ll N,K;
    cin >> N >> K;
    auto bitK = genbit(K);
    ll oneCount[50];
    for (int i = 0; i < 50; ++i) {
        oneCount[i] = 0;
    }
    for(int i = 0; i < N; i++){
        ll tmp;
        cin >> tmp;
        auto b = genbit(tmp);
        for (int j = 0; j < 50; ++j) {
            if(b[j]){
                oneCount[j]++;
            }
        }
    }
    for(int i = 0; i < 50; i++){
        //cout << oneCount[i] <<","<< endl;
    }
    bool judge = false;
    for (int i = 1; i <= 49; ++i) {
        int currentBit = 49 - i;
        if(bitK[currentBit]){
            memo[i][0] = memo[i-1][0] + (N - oneCount[currentBit]) * (1ll << currentBit);
            memo[i][1] = max(memo[i-1][1] + (oneCount[currentBit]) * (1ll << currentBit),memo[i-1][0] + (oneCount[currentBit]) * (1ll << currentBit));
            if(judge){
                memo[i][1] = max(memo[i][1],memo[i-1][1] +  (N - oneCount[currentBit]) * (1ll << currentBit));
            }
            judge = true;
        }else{
            memo[i][0] = memo[i-1][0] + (oneCount[currentBit]) * (1ll << currentBit);
            memo[i][1] = memo[i-1][1] + (oneCount[currentBit]) * (1ll << currentBit);
            if(judge){
                memo[i][1] = max(memo[i][1],memo[i-1][1] +  (N - oneCount[currentBit]) * (1ll << currentBit));
            }
        }
    }
    cout << max(memo[49][0],memo[49][1]) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,i,a=int(input()),1,0\n"
"while-~i*i<n:a+=n%i<1and n//i-1;i+=1\n"
"print(a)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 6980
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

void solve() {
    ll H,W;
    cin >> H >> W;
    vll row(H,0),col(W,0);
    vstr a(H);
    rep(i,H){
        cin >> a[i];
        if(a[i].find("#") != string::npos){
            row[i]=1;
        }
        rep(j,W){
            if(a[i][j]=='#'){
                col[j]=1;
            }
        }
    }

    rep(i,H){
        if(row[i]==1){
            rep(j,W){
                if(col[j]==1){
                    cout << a[i][j];
                }
            }
            cout << '\n';
        }
    }
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn=2e5+5;
const int INF=0x3f3f3f3f;
pair<ll,ll> p[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld%lld",&p[i].first,&p[i].second);
    sort(p+1,p+n+1);
    ll ans=0,minn1=INF,minn2=INF;
    for(int i=1;i<=n;i++)
    {
        ll cur1=p[i].first-p[i].second,cur2=p[i].first+p[i].second;
        ans=max(ans,max(cur1-minn1,cur2-minn2));
        minn1=min(minn1,cur1);
        minn2=min(minn2,cur2);
    }
    printf("%lld\n",ans);
    return 0;
}
/*
 dis=abs(xi-xj)+abs(yi-yj)
 we assume that xi>xj
 then dis=xi-xj+abs(yi-yj)
 if(yi<yj) then dis=xi-xj+yj-yi=(xi-yi)-(xj-yj)>(xi+yi)-(xj+yj)
 if(yi>yj) then dis=xi-xj+yi-yj=(xi+yi)-(xj+yj)>(xi-yi)-(xj-yj)
 */


Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  rep(i, N) {
    int a;
    cin >> a;
    A[i] = a - (i + 1);
  }

  sort(all(A));
  int n = (N / 2) + 1;
  long long ans = 0;
  long long x = A[n - 1];
  rep(i, N) ans += abs(A[i] - x);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int h,w,a,b,i,j,t;
  
  cin >> h >> w >> a >> b;
  
  for (i=0;i<h;i++){
    for (j=0;j<w;j++){
      t=0;
      if (i>=b) t++;
      if (j>=a) t++;
      cout << t%2;
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1280
#GCD, LCM
def gcd_base(a, b):
    while b!=0:
        a, b = b, a%b
    return a

def lcm(num_list):
    ans = 1
    for i in num_list:
        ans = ans * i // gcd_base(ans, i)
    return ans

n = int(input())
a = list(map(int, input().split()))
l = lcm(a)
mod = 10**9+7
total = 0
for i in a:
    total += l//i
print(total%mod)


Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;


int main() {
    
    
    int n;
    cin >> n;
    vector<int> a(n);
    
    int ret = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        ret ^= a[i];
    }
    
    if (ret == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

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

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

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

	cout << B - (A <= 5 ? B : A <= 12 ? B/2 : 0) << endl;

	return 0;
}

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

int main() {
  int A, B;
  char op;
  cin >> A;
  cin >> op;
  cin >> B;
  if(op=='+'){
    cout << A+B <<endl;
  }
  else if(op=='-'){
    cout << A-B <<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
			
		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			String S = sc.next();
			if(!map.containsKey(S)){
				map.put(S, 1);
			}
		}
		System.out.println(map.size());
		
		
      	sc.close();
    }
		
		
}


Measured memory_bytes: 66360
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    vector<P> plus, minus;
    int sum = 0;
    rep(i, n) {
        int tot = 0;
        int depth = 0;
        rep(j, sz(s[i])) {
            if (s[i][j] == '(') {
                tot++;
            } else {
                tot--;
                chmin(depth, tot);
            }
        }
        sum += tot;
        if (tot >= 0) {
            plus.emplace_back(-depth, -tot);
        } else {
            depth -= tot;
            tot = -tot;
            minus.emplace_back(-depth, -tot);
        }
    }
    if (sum != 0) {
        cout << "No" << endl;
        return 0;
    }
    sort(all(plus));
    sort(all(minus));
    auto check = [](vector<P>& v) {
                     int now = 0;
                     rep(i, sz(v)) {
                         P p = v[i];
                         int depth = -p.fi;
                         int tot = -p.se;
                         if (now + depth < 0) return false;
                         now += tot;
                     }
                     return true;
                 };
    if (check(plus) && check(minus)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 42512
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define MP make_pair
#define fs first
#define sc second
#define F first
#define S second
#define nl "\n"
#define asche cerr<<"Ekhane asche\n";
#define pf printf
#define sf scanf
#define mem(a,x) memset(a,x,sizeof(a))
#define SZ(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define one(x) __builtin_popcount(x)
#define fout(x) fixed<<setprecision(x)
#define BeatMeScanf ios_base::sync_with_stdio(false)
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}
//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace IO
{
    #define in() ( { int a ; scanf("%d",&a); a; } )
    #define LL() ( { ll a ; scanf("%lld",&a); a; } )
       #define ULL() ( { ull a ; scanf("%llu",&a); a; } )
    #define DD() ({ double a; scanf("%lf", &a); a;})
    #define CC() ( { char a ; scanf("%c",&a); a; } )
    #define pf1(a) printf("%d\n",a)
    #define pf1ll(a) printf("%lld\n",a)
}
using namespace IO;

const int mod=1e9+7;
const int N=3e5+9;
const double eps=1e-9;
const double PI=acos(-1.0);
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}


int32_t main()
{
    int n=in();
    int ans=0;
    for(int i=1;i<n-i;i++) ans++;
    pf1(ans);
    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stdio.h>
#include<string>
using namespace std;
int main() {
	long x,y,i, j=0,k=0, a, b;
	while (cin >> a >> b) {
		x = a + b;
		while (1) {
			j++;
			x /= 10;
			if (x == 0) {
				y = j;
				j = 0;
				break;
			}
		}
		cout << y << endl;
		
	}

	return 0;
}

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

s, b = 0, 0

for loop in range(N):
    t, a = map(int, input().split())

    if loop == 0:
        s, b = t, a
    else:
        k = max((s + t - 1) // t, (b + a - 1) // a)
        s, b = k * t, k * a
print(s + b)

Measured memory_bytes: 3060
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
/*
ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}*/
vector<ll> v(100005);
vector<ll> vis(100005, 0); ll c = 0, check = 0;
queue<ll>que;
void bfs(ll a, ll src) {
	vis[a] = src;
	que.push(src);
	while (!que.empty()) {
		src = que.front();
		for (ll x = 1; x <= v[src];x++) {
			if (vis[x] == 0) {
				c++;
				vis[x] = src;
				que.push(x);
			}
		}
		que.pop();
	}
}
int main() {
	ll k;
	cin >> h >> w >> k;
	rep(i, h+1) {
		rep(j, w+1) {
			if (i*(w-j)+j*(h-i) == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 1792
import sys
for line in sys.stdin:
    [a,b,c,d,e,f] = [float(x) for x in line.split()]
    x = (f-(c/b*e))/(d-(a/b*e))
    y = (f-(c/a*d))/(e-(b/a*d))
    print "%.3f %.3f" % (x if x else 0.0,y if y else 0.0)

Measured memory_bytes: 4252
use std::char::from_u32;
use std::collections::HashMap;
fn main() {
    let MOD: u128 = 10u128.pow(9) + 7;
    let n = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let n: u32 = buf
            .trim_end()
            .to_owned()
            .split_whitespace()
            .next()
            .unwrap()
            .parse()
            .unwrap();
        n
    };
    let s = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let s = buf.trim_end().to_owned();
        s
    };

    let mut map: HashMap<char, u128> = HashMap::new();
    for i in 0..26 {
        let c = from_u32('a' as u32 + i).unwrap();
        map.insert(c, 0);
    }

    for c in s.chars() {
        map.insert(c, map.get(&c).unwrap() + 1);
    }
    let mut ans: u128 = 1;
    for v in map.values() {
        ans *= *v + 1;
        ans %= MOD;
    }
    println!("{}", (ans - 1) % MOD)
}


Measured memory_bytes: 2268
#include <bits/stdc++.h>
using namespace std;
long long int jue(long long int aa)
{
    if(aa<0)
    {
        return -1*aa;
    }
    else
    {
        return aa;
    }
}
int main()
{
  int n;
  long long int a[210000];
  long long int s=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
      scanf("%lld",&a[i]);
      s+=a[i];
  }
  long long int s1=0;
  int i;
  long long int minn=999999999999999;
  for( i=0;i<n-1;i++)
  {
     s1+=a[i];
     if(jue(s-2*s1)<minn)
     {
         minn=jue(s-2*s1);
     }
  }
  printf("%lld\n",minn);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int H, W, N; cin >> H >> W >> N;
    vector<pair<int, int>> A;
    for (int i = 0; i < N; i++) {
        int X, Y; cin >> X >> Y;
        if (X >= Y) {
            A.emplace_back(X, Y);
        }
    }
    sort(A.begin(), A.end());
    int k = 0;
    for (auto p : A) {
        int x = p.first, y = p.second;
        if (x - y == k) {
            k++;
        } else if (x - y > k) {
            cout << x - 1 << endl;
            return 0;
        }
    }
    cout << H << endl;
    return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
    int x,y;
    char a[15],b[15],temp[15];
    scanf("%s%s%d%d%s",a,b,&x,&y,temp);
    if(strcmp(temp,a)==0)
    x--;
    else if(strcmp(temp,b)==0)
    y--;
    printf("%d %d\n",x,y);
   return 0;
}

Measured memory_bytes: 256
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
ans,pena=0,0
N,M=MI()
P=[0]*N
PENA=[0]*N
for i in range(M):
  p,s=input().split()
  p=int(p)
  p-=1
  if s=='AC':
    if P[p]==0:
      ans+=1
      P[p]=1
      if PENA[p]!=0:
        pena+=PENA[p]
  if s=='WA':
    if P[p]==0:
      PENA[p]+=1
print(ans,pena)


Measured memory_bytes: 10456
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    // y = (Y-2X)/2
    // x = (4X - Y)/2
    if( ( (y - 2 * x ) % 2) == 0 && ((4 * x - y ) % 2) == 0 ) {
      if( ( (y - 2 * x ) / 2) >= 0 && ((4 * x - y ) / 2) >= 0) {
        System.out.println("Yes");
      }else {
        System.out.println("No");
      }
    }else {
      System.out.println("No");
    }
  }

}


Measured memory_bytes: 35620
#include<iostream>
#include<functional>
#include<iomanip>
#include<vector>
#include<set>
#include<queue>
#include<utility>
#include<map>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>

#define LL long long
#define PB push_back
#define MP make_pair
#define INT_MAX 2147483647

using namespace std;

int N, R;
LL t[100000], e[100000];
int a[100000], b[100000];
LL c[100000];
vector<pair<int, LL>> rule[100000];

int main() {
	cin >> N >> R;
	for (int i = 0; i < N; i++) cin >> t[i] >> e[i];
	for (int i = 0; i < R; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
	}

	set<pair<LL, int>> st;
	for (int i = 0; i < N; i++) {
		st.insert(MP(t[i], i));
	}
	for (int i = 0; i < R; i++) {
		rule[b[i]].PB(MP(a[i], c[i]));
	}

	while (st.size() > 0) {
		int i = st.begin()->second;
		st.erase(st.begin());
		for (int j = 0; j < rule[i].size(); j++) {
			int memo = t[rule[i][j].first];
			if (memo > t[i] + rule[i][j].second - 1) {
				t[rule[i][j].first] = t[i] + rule[i][j].second - 1;
				auto itr = st.find(MP(memo, rule[i][j].first));
				st.erase(itr);
				st.insert(MP(t[rule[i][j].first], rule[i][j].first));
			}
		}
	}

	LL ans = 0;
	for (int i = 0; i < N; i++) {
		ans += t[i] * e[i];
	}
	cout << ans << endl;

	return 0;
}





Measured memory_bytes: 17948
N = int(input())
W = [int(i) for i in input().split()]
T = 0
answer = 0
for i in range(N-1):
    S1 = W[:i+1]
    S2 = W[i+1:]
    sum_S1 = sum(S1)
    sum_S2 = sum(S2)
    value = abs(sum_S1 - sum_S2)
    if(i == 0):
        T = value
    elif(T >= value):
        T = value
print(T)

Measured memory_bytes: 3064
n = int(input())
A = list(map(int, input().split()))

if n == 2:
    print(abs(A[0]-A[1]))
    exit()

cum_sum = [0]
for a in A:
    cum_sum.append(cum_sum[-1]+a)

ans = 10**9+1
for x in cum_sum[1:-1]:
    y = cum_sum[-1] - x
    ans = min(ans, abs(x-y))
print(ans)

Measured memory_bytes: 30680
//
//AtCoder Grand Contest 011
//A
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n,c,k;
    cin >> n >> c >> k;

    vector<int> t(n);
    REP(i, n) cin >> t[i];
    sort(ALL(t));


    int ans = 0;
    int idx = 0;
    while(idx<n){
        int st = -1;
        REP(i, c){
            if (st==-1){
                st = t[idx]+k;
                idx++;
            }else{
                if (st>=t[idx]) idx++;
                else break;
            }
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  
  int ans=0;
  for(int i=1; i<=N; i++){
    //int tmp=i/1000 + i%1000/100 + i%100/10 + i%10;
    int tmp=i, sum=0;
    while(tmp>0){
      sum+=tmp%10;
      tmp/=10;
    }
    if(sum>=A && sum<=B){
      ans+=i;
    }
  }
  cout << ans << endl;
}


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

long long number[100000000];
void NOD(){

    for(long long i=1;i<=10000000;i++){
        for(long long j=i;j<=10000000;j+=i){
            number[j]++;
        }
    }
}

int main(){

    NOD();

    long long N;
    cin>>N;

    long long res = 0;
    for(long long i=1;i<=N;i++){

        res = res + i*number[i];
    }

    cout<<res;



    return 0;
}

Measured memory_bytes: 81728
all = input()
japaneseAll = input()
mathAll = input()
japaneseCan = input()
mathCan = input()
if japaneseAll % japaneseCan == 0:
    japanseNeed = japaneseAll / japaneseCan
else:
    japanseNeed = japaneseAll / japaneseCan + 1
if mathAll % mathCan == 0:
    mathNeed = mathAll / mathCan
else:
    mathNeed = mathAll / mathCan + 1
if mathNeed < japanseNeed:
    print all - japanseNeed
else:
    print all - mathNeed


Measured memory_bytes: 4216
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<long long, int> cnt;
  long long sum = 0;
  for (int i = 0; i < N; ++i) {
    long long A;
    cin >> A;
    ++cnt[A];
    sum += A;
  }
  int Q;
  cin >> Q;
  for (int q = 0; q < Q; ++q) {
    long long B, C;
    cin >> B >> C;
    sum = sum - B * cnt[B] + C * cnt[B];
    cnt[C] += cnt[B];
    cnt[B] = 0;
    cout << sum << '\n';
  }
}


Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define PI acos(-1.0)
#define lowbit(x) (x&-x)

typedef long long ll;
typedef long double ld;
const int maxn=1e5+10;

int main()
{
    int a,b,c,d,e,f;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    int a1=0;
    double maxx=0;
    int s1,s2;
    while(a1*100*a<=f)
    {
        int a2=0;
        while(a1*100*a+a2*100*b<=f)
        {
            if(a1==0&&a2==0)
            {
                a2++;
                continue;
            }
            int c1=0;
            double num=(double)(a1*100*a+a2*100*b)*((double)e/100.0);
            while(c1*c+a1*100+a2*100<=f)
            {
                if(c1*c>num)
                    break;
                int d1=0;
                double t;
                while(c1*c+a1*100*a+a2*100*b+d1*d<=f)
                {
                    if(c1*c+d1*d>num)
                        break;
                    t=(double)(c1*c+d1*d)/(double)(a1*100*a+a2*100*b+c1*c+d1*d);
                    if(t>=maxx)
                    {
                        maxx=t;
                        s1=a1*100*a+a2*100*b+c1*c+d1*d;
                        s2=c1*c+d1*d;
                    }
                    d1++;
                }
                c1++;
            }
            a2++;
        }
        a1++;
    }
    printf("%d %d\n",s1,s2);
    return 0;
}


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

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;

  int st;
  int N = s.size();
  for ( int i = 0; i < N; i++ ) {
    if ( s[i] == '*' ) st = i;
  }

  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    for ( int j = i+1; j < N; j++ ) {
      if ( s[i] != '(' || s[j] != ')' ) continue;
      if ( st < i || j < st ) continue;
      int cnt = 0;
      bool flag = true;
      for ( int k = i+1; k <= j-1; k++ ) {
	if ( s[k] == '*' ) continue;
	if ( s[k] == '(' ) cnt++;
	else cnt--;
	if ( cnt < 0 ) flag = false;
      }
      if ( cnt != 0 ) continue;
      if ( flag ) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}



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


int main()
{
    int n,m; cin>>n>>m;
    int l=1,r=n;
    for (int i=1; i<=m; i++)
    {
    	int x,y;cin>>x>>y;
    	l=max(l,x);
    	r=min(r,y);
	}
	if (l<=r) cout << r-l+1;
	else cout << 0;
 } 

Measured memory_bytes: 256
from itertools import permutations
from math import factorial, hypot
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for t in permutations(XY):
    for (x1, y1), (x2, y2) in zip(t[1:], t[:-1]):
        ans += hypot(x1-x2, y1-y2)

print(ans / factorial(N))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    int N = S.length();
    
    bool flag = true;

    FOR(i, 0, (N-1)/2 - 1){
        if(S[i] != S[(N-1)/2 - 1 - i]) {
            flag = false;
            break;
        }
    }

    FOR(i, (N+3)/2 - 1, N-1){
        if(S[i] != S[N - 1 - i]) {
            flag = false;
            break;
        }
    }

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

    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  int a, b,t;
  cin >> a >> b >> t;
  int res = b*(t/a);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
// 0点

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	D := nextInt()
	c := nextInts(26)
	s := make([][]int, D)
	for i := range s {
		s[i] = nextInts(26)
	}

	last := make([]int, 26)
	for i := 1; i <= D; i++ {
		t := 0
		add := -(1 << 60)
		for j := 0; j < 26; j++ {
			old := last[j]
			last[j] = i
			diff := s[i-1][j]
			for k := range c {
				diff -= c[k] * (i - last[k])
			}
			if diff > add {
				t = j
				add = diff
			}
			last[j] = old
		}
		puts(t + 1)
		last[t] = i
	}
}


Measured memory_bytes: 2004
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N ;
    int A[N];
    for(int i=0; i < N; i++) cin >> A[i];
    int Mount[N] ={0};
    int temp =0;
    int plus=true;

    for(int i=0; i<N; i++){
        if(plus){
            temp += A[i];
            plus = false;
        }else{
            temp -= A[i];
            plus = true;
        }
    }
    Mount[0] = temp;
    for(int i=1; i<N; i++){
        Mount[i] = (A[i-1] - (Mount[i-1] / 2)) * 2;
    }

    for(int i=0; i<N; i++){
        cout << Mount[i] << " " ;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define PRIME1 99999883
#define PRIME2 99999893
#define EPS 0.00000001
using namespace std;

char RED[55],GREEN[55],ANS[55];

void func(){
	scanf("%s",GREEN);
	scanf("%s",ANS);

	queue<char> Q_R,Q_G,Q_OUT;

	int count = 0;

	for(int i = 0; RED[i] != '\0'; i++){
		Q_R.push(RED[i]);
		count++;
	}

	for(int i = 0; GREEN[i] != '\0';i++){
		Q_G.push(GREEN[i]);
		count++;
	}

	count++;

	int ans_index = 0,work_count = 0;
	char current;

	while(work_count < count){

		if(work_count == 0){
			current = Q_G.front();
			Q_G.pop();

		}else if(work_count == count-1){
			Q_OUT.push(current);
		}else{
			if(current == ANS[ans_index]){
				//push_down
				ans_index++;
				if(!Q_R.empty()){
					current = Q_R.front();
					Q_R.pop();
				}else{
					current = Q_G.front();
					Q_G.pop();
				}
			}else{
				//push_right
				Q_OUT.push(current);
				if(!Q_G.empty()){
					current = Q_G.front();
					Q_G.pop();
				}else{
					current = Q_R.front();
					Q_R.pop();
				}
			}
		}
		work_count++;
	}

	while(!Q_OUT.empty()){
		printf("%c",Q_OUT.front());
		Q_OUT.pop();
	}
	printf("\n");
}

int main(){

	while(true){
		scanf("%s",RED);
		if(RED[0] == '-')break;

		func();
	}

    return 0;
}

Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<random>
#include<ctime>
#include<cstdlib>
#include<unordered_map>
#include<string.h>
#include<iostream>
using namespace std;

signed main() {
	int n; cin >> n;
	int S = 0, a = 0, b = 0;
	for (int i = 0; i < n; i++) {
		int x, y, z; cin >> x >> y >> z;
		int k = abs(y - a) + abs(z - b);
		if (k <= x - S && (x - S - k) % 2 == 0) {
			S = x;
			a = y;
			b = z;
		}
		else {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using Int = int64_t;
int main() {
    Int N, M, C, ans = 0;
    cin >> N >> M >> C;
    vector<Int> A(M), B(M);
    for (auto& i : B) cin >> i;
    for (Int i = 0; i < N; i++) {
        Int sum = C;
        for (Int j = 0; j < M; j++) {
            cin >> A[j];
            sum += A[j] * B[j];
        }
        if (sum > 0) ans++;
    }
    cout << ans << endl;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int h[n], dp[n];
    for (int &i:h)
    {
        cin >> i;
    }
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i=2; i < n;++i)
    {
        dp[i] = min(abs(h[i] - h[i - 2]) + dp[i - 2], abs(h[i] - h[i - 1]) + dp[i - 1]);
    }
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
using P = pair<int,int>;

int main(void) 
{
   int n;
   cin >> n;
   vector<ll> l(n);
   rep(i,n) cin >> l[i];
   int ans = 0;
   rep(i,n-2){
       for(int j = i+1; j < n-1; j++){
           if(l[i] == l[j]) continue;
           for(int k = j+1 ; k < n; k++){
               if(l[i] == l[k] || l[j] == l[k]) continue;
               if( (l[i] +l[j] > l[k]) && (l[i] +l[k] > l[j]) && (l[k] +l[j] > l[i])) 
               {
                   ans ++;
                  // cout << i << " " << j << " " << k << endl;
               }
           }
       }
   }

   cout << ans << endl;
}

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

ll MOD = 1e9 + 7;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N), B(N), C(N);
  ll ret = 0;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      if (A[i] > A[j]) {
        B[i]++;
      }
    }
    for (int j = i + 1; j < N; j++) {
      if (A[i] > A[j]) {
        C[i]++;
      }
    }
    ret = (ret + MOD + (K * (K - 1) / 2) % MOD * B[i] % MOD) % MOD;
    ret = (ret + MOD + (K * (K + 1) / 2) % MOD * C[i] % MOD) % MOD;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef pair<int,int> P;

int main()
{
	int N;
	cin>>N;
	vector<P> cors;
	for( int i=0; i<N; i++ )
	{
		int x,y;
		cin>>x>>y;
		cors.push_back(P(x,y));
	}
	map<P,int> differs;
	int sum = 0;
	for( int i=0; i<N; i++ )
	{
		for( int j=i+1; j<N; j++ )
		{
			int dx = cors[j].first-cors[i].first, dy=cors[j].second-cors[i].second;
			differs[P(dx,dy)]++;;
			differs[P(-dx,-dy)]++;;
			if( sum < differs[P(dx,dy)] )
				sum = differs[P(dx,dy)];
		}
	}
	
	cout << N-sum << endl;
	return 0;
}

Measured memory_bytes: 384