akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vector<double> a(n);rep(i,n)cin>>a[i];
    sort(all(a));
    double c=a[n-1]/2;
    double tmp=inf;
    int ans;
    rep(i,n-1){
        if(abs(a[i]-c)<tmp){
            tmp=abs(a[i]-c);
            ans=a[i];
        }
    }
    cout<<(int)a[n-1]<<" "<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;
int main() {
	vector<int> a(10);
	string s, ans;
	cin >> s;
	if (s == "A")cout << 'T' << endl;
	if (s == "T")cout << 'A' << endl;
	if (s == "G")cout << 'C' << endl;
	if (s == "C")cout << 'G' << endl;
	return 0;
}


Measured memory_bytes: 3600
n = int(input())
h = 101
cnt = 0
for i in range(n):
    s = int(input())
    if s%10 != 0:
        h = min(h, s)
    cnt += s

if cnt%10==0:
    if h == 101:
        print(0)
    else:
        print(cnt-h)
else:
    print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	int n, t;
	cin >> n >> t;
	int will_stop = 0;
	int sum = 0;

	int next_push;
	cin >> next_push;
	int last_push = next_push;
	for (int i = 1; i < n; ++i) {
		cin >> next_push;
		sum += min(next_push - last_push, t);
		last_push = next_push;
	}
	sum += t;
	cout << sum << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
p=list(map(int,input().split()))
ans=0
import sys;sys.setrecursionlimit(10**9)
class u():#UnionFind f-根探し u-連結 s-連結? c-要素数
  def __init__(self,n):self.n,self.r=[-1]*n,[0]*n
  def f(self,x):
    if self.n[x]<0:return x
    else:self.n[x]=self.f(self.n[x]);return self.n[x]
  def u(self,x,y):
    x,y=self.f(x),self.f(y)
    if x==y:return
    elif self.r[x]>self.r[y]:self.n[x]+=self.n[y];self.n[y]=x
    else:self.n[y]+=self.n[x];self.n[x]=y;self.r[y]+=self.r[x]==self.r[y]
u=u(n)
for i in range(m):
  a,b=map(int,input().split())
  u.u(a-1,b-1)
for i in range(n):
  if p[i]==i+1:ans+=1
  elif u.f(i)==u.f(p[i]-1):ans+=1
print(ans)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  cout << N / 3 << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[][] a = new int[2][n];
    for(int i = 0; i < n; i++) {
    	a[0][i] = sc.nextInt();
    }
    for(int i = 0; i < n; i++) {
    	a[1][i] = sc.nextInt();
    }
    int x = 0;
    int y = 0;
    int max = 0;
    for(int i = 0; i < n; i++) {
    	x += a[0][i];
    	for(int j = i; j < n; j++) {
    		y += a[1][j];
    	}
    	if(max < x + y) {
    		max = x + y;
    	}
    	y = 0;
    }
    System.out.println(max);
}
}

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

using namespace std;

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

int H, W, n;
int sr, sc;
int has[2][4];
string s, t;

char dx[] = {'L', 'R', 'D', 'U'};
char dy[] = {'R', 'L', 'U', 'D'};

int check(char x, char y) {
    int g = (x == 'L' || x == 'R') ? sc : sr;
    int z = (x == 'L' || x == 'U') ? -1 : 1;
    int tar = (x == 'L' || x == 'R') ? W : H;
    rep(i, 0, n) {
        if (x == s[i]) g += z;
        if (g <= 0 || g > tar) return 1;
        if (y == t[i]) {
            if (g - z > 0 && g - z <= tar) g -= z;
        }
    }
    return 0;
}

int main() {
    cin >> H >> W >> n;

    cin >> sr >> sc;

    cin >> s;
    cin >> t;

    int ans = 0;

    rep(i, 0, 4) {
        if (check(dx[i], dy[i])) {
            cout << "NO";
            return 0;
        }
    }

    cout << "YES";

    return 0;
}


Measured memory_bytes: 776
import math
import numpy as np


#a, b, c, x = map(int, [input() for i in range(4)])
#z = list(map(int, input().split()))
#n, a, b = map(int, input().split())

#print(len(z))
#for i in z:
#    print(i)

#a = sorted(a,reverse = True)
#print(sum(a[::2]) - sum(a[1::2]))
#z = map(int, [input() for i in range(int(n))])

s = input()

s = s.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")


if s:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 21876
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, a[500001], l[1 << 20];
ll  dp[1 << 20][2], c0[500001], res;
set<int>st[1 << 20];

int main() {
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < (1 << 20); ++i) {
		dp[i][0] = 1;
		l[i] = N;
	}
	for (int i = 1; i <= N; ++i) {
		a[i] ^= a[i - 1];
	}
	for (int i = 1; i <= N; ++i) {
		l[a[i]] = min(l[a[i]], i);
		if (!a[i])c0[i] = 1;
		c0[i] += c0[i - 1];
	}
	for (int i = 1; i <= N; ++i) {
		dp[a[i]][0] += dp[a[i]][1] * (c0[i] - c0[l[a[i]]]);
		dp[a[i]][0] %= mod;
		dp[a[i]][1] += dp[a[i]][0];
		dp[a[i]][1] %= mod;
		l[a[i]] = i;
	}
	if (a[N]) {
		cout << dp[a[N]][0] << endl;
	}
	else {
		for (int i = 1; i < (1 << 20); ++i) {
			res += dp[i][1];
			res %= mod;
		}
		ll t = 1;
		for (int i = 0; i < c0[N] - 1; ++i) {
			t *= 2;
			t %= mod;
		}
		res += t;
		res %= mod;
		cout << res << endl;
	}
}


Measured memory_bytes: 75776
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	lint INF = 1000000000000;
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	lint Q;
	cin >> Q;
	lint com, b, c;
	lint M = -1*INF;
	lint m = INF;
	rep(i, Q) {
		M = -1*INF;
		m = INF;
		cin >> com >> b >> c;
		if (com == 0) {
			for (int j = b; j < c; j++) {
				m = min(m, A[j]);
			}
			cout << m << endl;
		}
		else if (com == 1) {
			for (int j = b; j < c; j++) {
				M = max(M, A[j]);
			}
			cout << M << endl;
		}
	}
}




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

typedef long long ll;

int main(void){
    ll N;
    cin >> N;
    
    vector<ll> A(100);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    ll money = 1000;
    ll kabu = 0;
    for(int i = 0; i <= N-2; i++){
        if(A[i] <= A[i+1]){
            kabu = money / A[i];
            money = money % A[i];
            
            money += kabu * A[i+1];
        }
    }
    
    cout << money << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

class UnionFind {
public:
    vector<int> par;
    int num;

    UnionFind(int n) : par(n, -1), num(n) {};

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    int size(int x) {
        return -par[root(x)];
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        num--;
        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (!uf.same(a, b)) uf.unite(a, b);
    }
    cout << max(0, uf.num - 1) << endl;
    return 0;
}


Measured memory_bytes: 3792
#include <stdio.h>

int main(void) {
	// your code goes here
	char s[5],i,a=0;
	scanf("%s",s);
	for(i=0;i<4;i++){
		if(s[i]=='+') a++;
		else a--;
	}
	printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a[12];
    a[0]=0;
    for (int i=1;i<12;i++)
    {
        a[i]=pow(26,i);
        a[i]=a[i]+a[i-1];
    }
    ll n;
    scanf("%lld",&n);
    int len=0;
    for (int i=0;i<12;i++)
    {
        if (a[i]>=n)
        break;
        len=i+1;
    }
    ll rem=n-a[len-1];
    char alp[26];
    for (int i=0;i<26;i++)
    alp[i]=(char)('a'+i);
    string s="";
    for (int i=len-1;i>=0;i--)
    {
        ll val=pow(26,i);
        ll div=(rem-1)/val;
        s=s+alp[div];
        rem=rem-div*val;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 4108
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
long long gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<pll> &a){sort(a.begin(),a.end()) ;}
//void myrev(vll &a){reverse(a.begin(),a.end()) ;}

const long int MAX = 10000000 ;

class SGT{
public :
	int n ;
	int d ;
	int dat[MAX] ;

	void init(vector<int> &a,int x){
		n = 1 ;
		d = x ;
		while(a.size()>n) n *= 2 ;
		for(int i=0;i<n;i++){
			if(i<a.size()) dat[i+n-1] = a.at(i) ;
			else dat[i+n-1] = d ;
		}
		for(int i=n-2;i>=0;i--){
			dat[i] = gcd(dat[i*2+1],dat[i*2+2]) ;
		}
	}

	void update(int i,int x){
		i += n-1 ;
		dat[i] = x ;
		while(i>0){
			i = (i-1)/2 ;
			dat[i] = gcd(dat[i*2+1],dat[i*2+2]) ;
		}
	}

	int query(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return d ;
		else if(a<=l&&r<=b) return dat[k] ;
		else return gcd(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r)) ;
	}

};

int main(){
	int n ; cin >> n ;
	vector<int> a(n) ;
	for(auto &i:a) cin >> i ;
	static SGT sgt ;
	sgt.init(a,0) ;
	int ans = 0 ;
	for(int i=0;i<n;i++){
//		cout << ans << endl ;
		int q ;
		if(i==0) q = sgt.query(1,n,0,0,sgt.n) ;
		else if(i==n-1) q = sgt.query(0,n-1,0,0,sgt.n) ;
		else q = gcd(sgt.query(0,i,0,0,sgt.n),sgt.query(i+1,n,0,0,sgt.n)) ;
		if(q>ans) ans = q ;
	}
	cout << ans << endl ;
//	for(int i=0;i<7;i++) cout << sgt.dat[i] << " " ;
}


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

int main(){
	int n;
  	cin >> n;
  
	ll ans = 0;
  	rep(i, n + 1){
    	if(i % 3 == 0) continue;
      	if(i % 5 == 0) continue;
      	ans += i;
    }
  	
  	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 200005
#define maxK 305
#define MOD 1000000007
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n;
ii p[maxN];

int main () {
    scanf("%d", &n);
    fto(i, 1, 2*n) {
        scanf("%d", &p[i].ff);
        p[i].ss = (i > n);
    }

    sort(p+1, p+2*n+1);

    int cnt = 0, ans = 1;
    fto(i, 1, 2*n) {
        if (p[i].ss == 0) {
            if (cnt < 0) ans = (1LL*ans*(-cnt))%MOD;
            ++cnt;
        } else {
            if (cnt > 0) ans = (1LL*ans*cnt)%MOD;
            --cnt;
        }
    }

    printf("%d", ans);

    return 0;
}


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

int main() {
	int K, A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  	cin >> K;
	cout << A[K-1] << "\n";
}

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

//既存のsort関数で数字のときと同様にsortすればOK！

//使い方　昇順にソートしたいときは、23行目、
//   　　　降順にソートしたいときは、24行目をコメントアウトする

int main()
{
    ll N;
    ll count = 1;
    ll count2 = 0;
    ll max = 1;
    string t;
    vector<string> S;
    scanf("%lld", &N);
    rep(i, N)
    {
        cin >> t;
        S.push_back(t);
    }
    std::sort(S.begin(), S.end()); //昇順にソート
                                   //  std::sort(S.begin(), S.end(), greater<string>()) ;//降順にソート
    rep(i, N)
    {
            if (i<(N-1)&&S[i] == S[i + 1])
            {
                count++;
            }
        else
        {
            if (count > max)
                max = count;
            count = 1;
        }
    }
    // cout<<max<<endl;
    rep(i, N)
    {
        if (i < (N - 1) && S[i] == S[i + 1])
        {
            count++;
            if (i == (N - 1))
            {
                count++;
                if (count == max)
                {
                    cout << S[i] << endl;
                }
            }
        }
        else
        {
            if (count == max)
                cout << S[i] << endl;
            count = 1;
        }
    }
    return 0;
}


Measured memory_bytes: 15984
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int main()
{
    int N;
    cin>>N;
    vector<double> result;
    double c,d;
    for (int i = 0;i<N;i++){
        cin>>c>>d;
        double a = min(c,d);
        double b = max(c,d);
        double t = a*b;
        if(a==b || a==b-1){
            result.push_back(2*a-2);
        }
        else{
            double c1 = floor(sqrt(t))==sqrt(t)?sqrt(t)-1:floor(sqrt(t));
            if(c1*(c1+1)>=t)
                result.push_back(2*c1-2);
            else
                result.push_back(2*c1-1);
        }

    }
    for(int j = 0;j<result.size();j++)
        cout<<(int)result[j]<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
string s;
char buf[N];
ll ans=0,book=0,val[N],num[2020][225],vn[2020][225];
vector<ll> v;
int main(){
	ll i,j,x=1;
	scanf("%s",&buf);
	s=buf;
	for(i=0;i<224;i++)
	{
		v.push_back(x);
		x=(x*10)%2019;
	}
	for(i=0;i<2019;i++)
	{
		for(j=0;j<224;j++)
		{
			vn[(i*v[j])%2019][j]=i;
		}
	}
	val[0]=0;
	for(i=0;i<s.size();i++)
	{
		val[i+1]=(val[i]*10+(s[i]-'0'))%2019;
	}
	for(i=0;i<=s.size();i++)
	{
		for(j=0;j<224;j++)
		{
			ans+=num[vn[val[i]][(i+224-j)%224]][j];
		}
		num[val[i]][i%224]++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12636
// 再提出.
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define a first
#define b second
#define all(x) x.begin(), x.end()

int main(){
    
    // 1. 入力情報.
    int N, K;
    map<char, int> m;
    scanf("%d %d", &N, &K);
    rep(i, N){
        char c[22];
        scanf("%s", c);
        m[c[0]]++;
    }
    
    // 2. データを保存.
    vector<pair<int, char>> v;
    for(auto &i : m) v.push_back({i.b, i.a});
    
    // 3. 最大で何回のKUPCを開催できるか？
    // ex.
    // 6 2
    // DAWN
    // DAYLIGHT
    // DAZZLE
    // BAKERY
    // BARRIER
    // ABSENCE
    // -> 3回 が 正しいので, ロジック修正.
    int ans = 0;
    while(1){
        int k = K;
        sort(all(v));
        reverse(all(v));
        for(auto &p : v){
            if(p.a > 0){
                p.a--;
                k--;
            }
            if(!k) break;
        }
        if(k) break;
        else  ans++;
    }
    
    // 4. 出力.
    printf("%d\n", ans);
    return 0;
    
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> t(n, 0);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    t[a-1]++;
    t[b-1]++;
  }
  for (int i = 0; i < n; ++i) {
    cout << t[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int A,B;
  cin>>A>>B;
  if((A+B)%2==0){
    cout<<(A+B)/2<<endl;
  }
  else{
    cout<<"IMPOSSIBLE"<<endl;
  }
}
  

Measured memory_bytes: 256
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O2")
// #pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
// #define int ll
#define pb push_back
#define pob pop_back
#define __bp __builtin_popcount
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pdd = pair<ld,ld>;
using vint = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
#define F first
#define S second
const int N = 2e5+5;//(1 << 18) + 5;
//const ll inf = 1e18+7;
const int Inf = 1e9+7;
const ll INF = 1e18+7;
const int Mod = 998244353;
const ld eps = 1e-9;
#ifndef M_PI
#define M_PI 3.1415926535
#endif

void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//	freopen("sweets.in", "r", stdin);
//	freopen("sweets.out", "w", stdout);
//	cout << setprecision(7) << fixed;
}

int n, k;
ll pf[N], cnt[N];
int l[11], r[11];

void solve()
{
	cin >> n >> k;
	for (int i = 0; i < k; ++i)
		cin >> l[i] >> r[i];
	cnt[1] = 1;
	pf[1] = 1;
	for (int i = 1; i <= n; ++i)
	{
		for (int seg = 0; seg < k; ++seg)
		{
			cnt[i] += pf[max(0, i - l[seg])] - pf[max(0, i - r[seg] - 1)];
			(cnt[i] += Mod) %= Mod;
		}
		pf[i] = pf[i - 1] + cnt[i];
		pf[i] %= Mod;
	}
	cout << cnt[n] << '\n';
}

signed main()
{
	io();
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		// solve();
		solve();
//		cerr << '\n';

	}
}

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

using namespace std;

int main(void)
{
	string S;
	char t;
	std::cin >> S;
	uint32_t len(S.length());
	uint32_t count(0);
	for (size_t i = 0; i < len; ++i)
	{
		cin >> t;
		if (S[i] != t) count++;
	}

	cout << count;
	return 0;
}

Measured memory_bytes: 3312
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/04/04.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC162
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__

int N;

void prgb(int a, int b, int c){
  cout << a << " " << b << " " << c << endl;
}

void solve(void){
  
  string S;

  vector<int> R;
  vector<int> G;
  vector<int> B;

  ll ans=0;
  
  cin >> N >> S;

  
  REP(i,N){
    if(S[i]=='R'){R.push_back(i+1);}
    if(S[i]=='G'){G.push_back(i+1);}
    if(S[i]=='B'){B.push_back(i+1);}
  }
  
//  cout << "R" << R.size() << endl;
//  cout << "G" << G.size() << endl;
//  cout << "B" << B.size() << endl;

  ll tmp=R.size()*G.size()*B.size();
  
  if (tmp==0){cout <<"0"<<endl; return;}
  
  REP(i,N-1){
    REP2(j,i+1,N){
      int k=2*j-i; // j+(j-i)
      //cout << i+1 << " " << j+1 << " " << k+1 << endl;
      if(k>=N){
        //cout <<" XXX" << endl;
        continue;}
      //cout << " = " << S[i] << " " << S[j] << " " << S[k];
      if(S[i]==S[j]){
        //cout <<" AAA" << endl;
        continue;}
      if(S[j]==S[k]){
        //cout <<" BBB" << endl;
        continue;}
      if(S[i]==S[k]){
        //cout <<" CCC" << endl;
        continue;}
      ans++;
      //cout << endl;
    }
  }
  
  ans = tmp-ans;
 
  cout << ans <<endl;
   
  
  return;
   
}



#define TESTCASES 1

int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}



Measured memory_bytes: 3704
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String answer;
		switch(S.length()){
			case 2:
			answer = S;
			break;
			case 3:
			StringBuffer sb = new StringBuffer(S);
			answer = sb.reverse().toString();
			break;
			default:
			answer = "";
		}
		System.out.println(answer);
		System.out.flush();
		return;
	}
}


Measured memory_bytes: 22612
import re

def revPolish(f):
    f = re.sub(r'(\-?\d+\.?\d*)\s(\-?\d+\.?\d*)\s([\+\-\*/])(?!\d)',
        lambda m: str(eval(m.group(1) + m.group(3) + m.group(2))),
        f)
    if f[-1] in ('+','-','*','/'):
        return revPolish(f)
    else:
        return f

print(revPolish(input()))


Measured memory_bytes: 6600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <iterator>

using namespace std;

long long int A[200000], D[200000];

int main(){
	
	long long int N, T, Q;
	
	cin >> N >> T >> Q;
	
	long long int const LL_MAX = 1000000000000000001;
	long long int east = LL_MAX;
	
	vector<long long int> v;
	
	for(int i = 0; i < N; i++){
		cin >> A[i] >> D[i];
		if(D[i] == 1){
			east = A[i];
		}else{
			if(east == LL_MAX){
				continue;
			}
			v.push_back((east + A[i]) / 2);
			east = LL_MAX;
		}
	}
	/*
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
	*/
	for(int i = 0; i < Q; i++){
		int num;
		cin >> num;
		num--;
		int index = distance(v.begin(), lower_bound(v.begin(), v.end(), A[num]));
		if(D[num] == 2){
			index--;
		}
		//cout << index << " ";
		if(index < 0 || index >= v.size()){
			if(D[num] == 1){
				cout << A[num] + T << endl;
			}else{
				cout << A[num] - T << endl;
			}
		}else{
			if(D[num] == 1){
				cout << min(A[num] + T, v[index]) << endl;
			}else{
				cout << max(A[num] - T, v[index]) << endl;
			}
		}
	}
	
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;
    cin>>n;

    set<string> s;

    rep(i,n){
        string tmp;
        cin>>tmp;
        s.insert(tmp);
    }

    cout<<s.size()<<"\n";

    return 0;
}

Measured memory_bytes: 19180
from fractions import Fraction
def inverse(f):
  return Fraction(f.denominator, f.numerator)

n = int(input())
a = [int(x) for x in input().split()]

r = 0
s = 0
while s < n:
  r += Fraction(1, a[s])
  s += 1

print(inverse(r).numerator/inverse(r).denominator)

Measured memory_bytes: 5304
#include<iostream>

using namespace std;

int main()

{
    int a, b;
    cin >>a;
   
    while (a>0)
    {
        if(a%10 == 7){
            cout << "Yes"<<endl;
            
            return 0;
        };
        a= a/10;
    }
    cout << "No"<<endl;
            return 0;

}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
long long l1,l2,i,gs1,gs2;
string st1,st2;
int main()
{
	cin>>st1;
	cin>>st2;
	l1=st1.size();l2=st2.size();
	for(i=1;i<=l1+l2;i++)
	{
		if(i%2!=0) {cout<<st1[gs1];gs1++;}
		if(i%2==0) {cout<<st2[gs2];gs2++;}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
using namespace std;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    vector<int> A;
    vector<int> B;
    int odd = 0;
    for (int i = 0; i < m; i++) {
        int t;
        scanf("%d", &t);
        A.push_back(t);
        odd += t & 1;
    }
    if (odd > 2) {
        puts("Impossible");
    } else {
        if (A.size() == 1) {
            if (A[0] == 1) {
                B = {1};
            } else {
                B = {A[0] - 1, 1};
            }
        } else {
            for (int i = 1; i < m - 1; i++) {
                if (A[i] & 1) {
                    if (A[0] & 1) {
                        swap(A[i], A[m - 1]);
                    } else {
                        swap(A[i], A[0]);
                    }
                }
            }
            B.push_back(A[0] + 1);
            for (int i = 1; i < m - 1; i++) {
                B.push_back(A[i]);
            }
            if (A[m - 1] != 1)
                B.push_back(A[m - 1] - 1);
        }
        assert(accumulate(B.begin(), B.end(), 0) == n);
        for (int i = 0; i < m; i++) {
            printf("%d ", A[i]);
        }
        printf("\n");
        printf("%d\n", (int)B.size());
        for (int i = 0; i < (int)B.size(); i++) {
            printf("%d ", B[i]);
        }
        printf("\n");


    }

}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//long long n, A[1000000000];
	//ll n, m, q;
	string s, t;
	ll n, k;
	ll x[2005];
	ll y[2005];
	ll w;
	cin >> w;
	a = 10000000000;
	b = 1;
	for (ll i = 1; i <= pow(ll(log10(w)), ll(10))/(ll(100)); i *= 10)
	{
		//a = min(a, abs((w - (w % (int(pow(i, 10))))) / int(pow(i - 3, 10)) - 753));
		if (99 < ((w - (w % i) - (w / (1000 * i)) * (1000 * i))) / i && ((w - (w % i) - (w / (1000 * i)) * (1000 * i))) / i < 1000)
		{
			a = min(a, abs(((w - (w % i) - (w / (1000 * i)) * (1000 * i))) / i - 753));
			//cout <<a<< endl;
			//cout << ((w - (w % i) - (w / (1000 * i)) * (1000 * i))) / i << endl;

		}
		//cout << abs((w - (w % 10000000)) / 10000000) << endl;
		
		//a = min(a, abs((w - (w % 1000000) - (w / 1000000000)) / 1000000 - 753));
		//cout << abs((w - (w % 1000000) - (w / 1000000000)* 1000000000) / 1000000) << endl;

		//a = min(a, abs((w - (w % 100000)-(w/100000000))/100000 - 753));
		//cout << abs(((w - (w % 100000) - (w / 100000000) * 100000000)) / 100000) << endl;
		//cout << abs(((w - (w % 10000) - (w / 10000000) * 10000000)) / 10000) << endl;
		//cout << abs(((w - (w % 1000) - (w / 1000000) * 1000000)) / 1000) << endl;
		//cout << abs(((w - (w % 100) - (w / 100000) * 100000)) / 100) << endl;
		//cout << abs(((w - (w % 10) - (w / 10000) * 10000)) / 10) << endl;
		//cout << abs(((w - (w % 1) - (w / 1000)* 1000)) / 1) << endl;
	}

	cout << a << endl;
	//cout <<  << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え


Measured memory_bytes: 512
N = int(input())
a = N % 10
if a == 2 or a == 4 or a == 5 or a == 7 or a == 9:
  print("hon")
elif a == 0 or a == 1 or a == 6 or a == 8:
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

void print(int A[], int N){
	rep(i, N){
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void bubbleSort(int A[], int N){
	int count = 0;

	bool flag = true;
	while (flag){
		flag = false;
		for (int i = N - 1; i >= 1; i--){
			if (A[i] < A[i - 1]){
				int temp = A[i];
				A[i] = A[i - 1];
				A[i - 1] = temp;
				flag = true;
				count++;
			}
		}
	}

	print(A, N);
	cout << count << endl;
}

int main() {

	int N;
	cin >> N;

	const int MAX_N = 10000;
	int A[MAX_N];

	rep(i, N){ cin >> A[i]; }

	bubbleSort(A, N);
}

Measured memory_bytes: 3224
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
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; }
using namespace std;


int main(){
  ll N,ans=1;
  cin>>N;
  
  ll A[N+1];
  RREP(i,N+1) cin>>A[i];
  
  
  ll L[N+1][3];
  REP(i,N+1){
    REP(j,3){
      L[i][j]=0;
    }
  }
  
  for(int i=1; i<=N; ++i){
    ll cnt=0;
    
    for(int j=0; j<3; ++j){
      L[i+1][j]=L[i][j];
      if(L[i][j]==A[i]) cnt++;
    }
    if(L[i][0]==A[i]) L[i+1][0]++;
    else if(L[i][1]==A[i]) L[i+1][1]++;
    else if(L[i][2]==A[i]) L[i+1][2]++;
    ans*=cnt;
    ans%=MOD;
  }
  
  co(ans);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N,K;
	cin >> N >> K;
	int ans0 =0;
	vector< vector<int> > D(K,vector<int>(K,0));
	for(int i =0; i < N; i++) {
		int a,b,c;
		string s;
		cin >> a >> b >> s;
		c =(s == "W")?1:-1;
		a -=(a/(2*K))*(2*K);
		b -=(b/(2*K))*(2*K);
		while(a < 0) a +=K, c *=-1;
		while(a >= K) a -=K, c *=-1;
		while(b < 0) b +=K, c *=-1;
		while(b >= K) b -=K, c *=-1;
		if(abs(D[a][b]) > abs(D[a][b]+c)) ans0++;
		D[a][b] +=c;
	}

	vector<int> cnt[2];
	for(int i =0; i < 2; i++) cnt[i].resize(K,0);
	for(int i =0; i < K; i++) for(int j =0; j < K; j++)
		cnt[(D[i][j] > 0)][j] +=abs(D[i][j]);
	int ans =0;
	for(int i =0; i <= K; i++) {
		int sumr[2] ={0,0}, suml[2] ={0,0};
		for(int j =0; j < K; j++) for(int k =0; k < 2; k++)
			sumr[k] +=cnt[k][j];
		for(int j =0; j <= K; j++) {
			ans =max(ans,max(sumr[0]+suml[1],suml[0]+sumr[1]));
			if(j < K) for(int k =0; k < 2; k++) {
				sumr[k] -=cnt[k][j];
				suml[k] +=cnt[k][j];
			}
		}
		if(i < K) 
			for(int j =0; j < K; j++) {
				cnt[(D[i][j] > 0)][j] -=abs(D[i][j]);
				cnt[(D[i][j] < 0)][j] +=abs(D[i][j]);
			}
	}

	cout << ans+ans0 << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int n;
  	cin>>n;
	vector<int>a(n);
  	vector<int>b(n);
  	vector<int>c(n-1);
  	for(int i=0;i<n;i++){
    	cin>>a[i];
    }
  	for(int i=0;i<n;i++){
    	cin>>b[i];
    }
  	for(int i=0;i<n-1;i++){
    	cin>>c[i];
    }
  	int sum=0;
  	for(int i=0;i<n;i++){
    	sum=sum+b[a[i]-1];
      if(i>0){
        if(a[i]-a[i-1]==1){
      	sum=sum+c[a[i-1]-1];
      	}
      }
      
    }
  	cout<<sum<<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;


int main() {
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; ++i) {
		sum += i;
		if (sum < n)
			continue;
		for (int j = i; j >= 1; --j) {
			if (n >= j) {
				n -= j;
				cout << j << "\n";
			}
		}
		return 0;
	}
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <cmath>
#include <sstream>
#include <queue>
#include <map>
#include <cstring>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
    int N;
    long long result = 1;
    long long T[100000];
    long long A[100000];
    bool definit[100000] = {};
    cin >> N;
    definit[0] = true;
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 1; i < N; i++) {
        if (T[i] > T[i - 1]) {
            definit[i] = true;
        }
    }
    if (definit[N - 1] && A[N - 1] != T[N - 1]) {
        cout << 0 << endl;
        return 0;
    } else {
        definit[N - 1] = true;
    }
    for (int i = N - 2; i >= 0; i--) {
        if (A[i] > A[i + 1]) {
            if (definit[i] && A[i] != T[i]) {
                cout << 0 << endl;
                return 0;
            }
            definit[i] = true;
            if (A[i] > T[i]) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    for (int i = 1; i < N - 1; i++) {
        if (!definit[i]) {
            result = (result * (min(T[i], A[i]) % 1000000007)) % 1000000007;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 5e18;

void solve()
  {
   int x;
   cin>>x;
   x = 1 - x;
   cout<<x;
  } 
int32_t main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
  /* int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    cin>>a>>b;
    int ans=-1e9;
    ans=max(ans,a+b);
    ans=max(ans,a-b);
    ans=max(ans,a*b);
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  int ans = 0;
  int a;
  while(n--){
    cin>>a;
    while(a%2==0){
      a/=2;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));
    int N = sc.nextInt(), K = sc.nextInt();
    int[] trees = new int[N];
    IntStream.range(0, N).boxed().forEach(i->trees[i]=sc.nextInt());
    Arrays.sort(trees);

    int shift = K-1;
    int ans = Integer.MAX_VALUE;
    for (int i = 0; i < N-shift; i++) {
        int min = trees[i];
        int max = trees[i+shift];
        int sub = max - min;
        if (sub<ans){
            ans = sub;
        }
    }
    out.println(ans);
    out.close();
  }

  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


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

int n, m, a[53], b[53], dp[53][53][53][53][2][4], INF = (1 << 30);

int sum(int ty, int L, int R) {
	int sum = 0;
	if (ty == 1) {
		for (int i = L; i <= R; i++) { if (a[i] >= 1) sum += a[i]; }
	}
	if (ty == 2) {
		for (int i = L; i <= R; i++) { if (b[i] >= 1) sum += b[i]; }
	}
	return sum;
}

int solve(int pos1, int pos2, int a1, int a2, int turn, int pass) {
	if (dp[pos1][pos2][a1][a2][turn][pass] != INF) return dp[pos1][pos2][a1][a2][turn][pass];
	if (pass == 3) return 0;

	int ret = 0;
	if (turn == 0) {
		ret = -INF;
		// カードを置く場合
		if (pos1 <= n) {
			if (a[pos1] == -1) ret = max(ret, solve(pos1 + 1, pos2, a1, pos2, turn ^ 1, 0));
			else ret = max(ret, solve(pos1 + 1, pos2, a1, a2, turn ^ 1, 0));
		}

		// パスする場合
		ret = max(ret, solve(pos1, pos2, pos1, pos2, turn ^ 1, pass + 1) + sum(1, a1, pos1 - 1) - sum(2, a2, pos2 - 1));
	}
	if (turn == 1) {
		ret = INF;
		// カードを置く場合
		if (pos2 <= m) {
			if (b[pos2] == -1) ret = min(ret, solve(pos1, pos2 + 1, pos1, a2, turn ^ 1, 0));
			else ret = min(ret, solve(pos1, pos2 + 1, a1, a2, turn ^ 1, 0));
		}

		// パスする場合
		ret = min(ret, solve(pos1, pos2, pos1, pos2, turn ^ 1, pass + 1) + sum(1, a1, pos1 - 1) - sum(2, a2, pos2 - 1));
	}
	dp[pos1][pos2][a1][a2][turn][pass] = ret;
	return ret;
}

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= m; i++) cin >> b[i];
	for (int i = 0; i < 2809; i++) {
		for (int j = 0; j < 2809; j++) {
			for (int k = 0; k < 8; k++) dp[i / 53][i % 53][j / 53][j % 53][k / 4][k % 4] = INF;
		}
	}
	int ret = solve(1, 1, 1, 1, 0, 0);
	cout << ret << endl;
	return 0;
}


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

#define ll long long;
const int mx = 2e5;


int main(void){
  
  string S;
  cin >> S;
  
  if(S[2]==S[3]){
    if(S[4]==S[5]){
      cout << "Yes";
      return 0;
    }
  }
  cout <<"No";


  return 0;
}

Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use std::collections::VecDeque;
use std::io::stdin;
use std::str::FromStr;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let mut sc = Scanner::new();
    let s = sc.next_string();
    let s = s.chars().collect_vec();
    let t = "CODEFESTIVAL2016".chars().collect_vec();
    
    let mut ans = 0;
    for i in 0..t.len() {
        if s[i] != t[i] {
            ans += 1;
        }
    }
    
    println!("{}", ans);
}

pub struct Scanner {
    buf: VecDeque<String>,
}

impl Scanner {
    pub fn new() -> Self {
        Self {
            buf: VecDeque::new(),
        }
    }
    
    fn scan_line(&mut self) {
        while self.buf.is_empty() {
            let mut s = String::new();
            stdin().read_line(&mut s).unwrap();
            let mut iter = s.split_whitespace().peekable();
            if iter.peek().is_none() {
                panic!("There is no input!");
            }
            
            for si in iter {
                self.buf.push_back(si.to_string());
            }
        }
    }
    
    pub fn next<T: FromStr>(&mut self) -> T {
        self.scan_line();
        self.buf.pop_front().unwrap().parse().unwrap_or_else(|_| panic!("Couldn't parse!"))
    }
    
    pub fn next_usize(&mut self) -> usize {
        self.next()
    }
    
    pub fn next_isize(&mut self) -> isize {
        self.next()
    }
    
    pub fn next_chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect_vec()
    }
    
    pub fn next_string(&mut self) -> String {
        self.next()
    }
    
    pub fn fill_vec_line<T: FromStr>(&mut self, v: &mut Vec<T>) {
        for vi in v {
            *vi = self.next();
        }
    }
    
    pub fn fill_vec<T: FromStr>(&mut self, v: &mut Vec<Vec<T>>) {
        for vi in v {
            for vii in vi {
                *vii = self.next();
            }
        }
    }
    
    pub fn make_vec_line<T: FromStr + Default + Clone>(&mut self, i: usize) -> Vec<T> {
        let mut v = vec![Default::default(); i];
        self.fill_vec_line(&mut v);
        v
    }
    
    pub fn make_vec<T: FromStr + Default + Clone>(&mut self, i: usize, j: usize) -> Vec<Vec<T>> {
        let mut v = vec![vec![Default::default(); j]; i];
        self.fill_vec(&mut v);
        v
    }
}


Measured memory_bytes: 2108
def sum_count(n,s,r):
    count = 0
    if n==1:
        if (r<=s and s<=9):
            return 1
        else:
            return 0
    else:
            return sum([sum_count(n-1,s-i,i+1) for i in range(r,9)])

while True:
    n,s=map(int,raw_input().split(" "))
    if n==0 and s==0:
        break
    print sum_count(n,s,0)
    

Measured memory_bytes: 4216
def solve():
    n = int(input())
    a = []
    a.append(0)
    a_ = list(map(int, input().split()))
    a = a + a_
    a.append(0)

    one = [-1 for i in range(n+1)]


    # 差分1
    for i, a_ in enumerate(a):
        if i != n+1:
            one[i] = abs(a[i+1] - a[i])

    #print(n, len(a), a, one)

    two = [-1 for i in range(n+1)]
    for i, a_ in enumerate(a):
        if i == 0 or i == n+1:
            pass
        else:
            two[i] = abs(a[i+1] - a[i-1])


    l = sum(one)

    for i in range(1, n+1):
        print(l - one[i] - one[i-1] + two[i])

solve()

Measured memory_bytes: 15936
X = gets.chomp.to_i

coins_500yen = X / 500

coins_5yen = (X % 500) / 5

coins_100yen = ((X % 500) % 5) / 100

coins_50yen = (((X % 500) % 5) % 100) / 50

coins_10yen = ((((X % 500) % 5) % 100) % 50) / 10

coins_1yen = ((((X % 500) % 5) % 100) % 50) % 10

puts coins_500yen * 1000 + coins_5yen * 5

Measured memory_bytes: 1788
#include <stdio.h>

int main(void)
{
	int n;
	
	scanf("%d",&n);
	
	int l[n][2];
	
	int sum=0;
	
	for(int i=0;i<n;i++){
		scanf("%d",&(l[i][0]));
		scanf("%d",&(l[i][1]));
		
		sum=sum+l[i][1]-l[i][0]+1;
	}
	
	printf("%d\n",sum);
	
	return 0;
}

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

int N;
int d[101];

int main(){
cin>>N;
for(int i=0;i<=N;i++)cin>>d[i];
sort(d, d + N, greater<int>());

int count = 1;
for(int i=0;i<N-1;i++){
        if(d[i]!=d[i+1]) count++;
}
cout<<count<<endl;
}

Measured memory_bytes: 256