akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007

int n,fr[210]={},fb[210]={},cnt=0;
tuple<int,int,int> r[210],b[210];

int main(int argc, char const *argv[]) {
  std::cin >> n;
  for(int i=0; i<n; i++){
    int x,y;
    std::cin >> x >> y;
    r[i]=make_tuple(y,x,i);
  }
  for(int i=0; i<n; i++){
    int x,y;
    std::cin >> x >> y;
    b[i]=make_tuple(x,y,i);
  }
  sort(r,r+n);
  sort(b,b+n);

  for(int i=0; i<n; i++){
    int bx,by,idb;
    tie(bx,by,idb)=b[i];
    for(int j=n-1; j>=0; j--){
      int rx,ry,idr;
      tie(ry,rx,idr)=r[j];
      if(rx<bx && ry<by && fr[j]==0 && fb[i]==0){
          fr[j]++;
          fb[i]++;
          cnt++;
          break;
      }
    }
  }
  std::cout << cnt << '\n';
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
    using namespace std;
     
    int main()
    {
      
      int x,y;
      
      cin>>x>>y;
      if(1<=x&&x<=9&&y>=1&&y<=9)
      {
        cout<<x*y<<endl;
      }
      else
        cout<<"-1"<<endl;
      
      return 0;
    }

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,i,price;
    long long int average=0;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d",&price);
        average+=price;
    }
    average/=n;
    printf("%lld\n",average);
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define td(x) x.begin(),x.end()
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define MAXN 100100
using namespace std;

int prel[MAXN],prer[MAXN];
int pre[MAXN];
int32_t main(){
	//ios_base::sync_with_stdio(0);
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	pre[0]=0;
	for(int i=0;i<n;){
		char atual = s[i];
		int x=-1;
		while(i<n && s[i]==atual){
			x++;
			pre[i+1] = pre[i]+(x==0 ? 0 : 1);
			i++;
		}
	}
	int best=0;
	int in = 0;
	int r=0;
	
	for(int ini=0;ini<n;){
	
		if(r==n)break;
		if(in>=k){
			while(ini<n && s[ini]=='R')ini++;
			while(ini<n && s[ini]=='L'){
				ini++;
			}
			in--;
		}
		while(in<k && r<n){
		while(r<n && s[r]=='R'){
			r++;
		}
		if(in<k){
			in++;
			while(r<n && s[r]=='L'){
			   r++;
			}
		}
		}
		
		while(r<n && s[r]=='R')r++;
		if(r==n){
		best = max(best,r-ini-1 + pre[ini-1+1] + pre[n] - pre[r]);
		break;
		}
	//	cout<<r<<" "<<ini<<" "<<in<<" "<<pre[n]<<" "<<pre[r]<<endl;
			best = max(best,r-ini-1 + pre[ini-1+1] + pre[n] - pre[r]);	
	}
	
	in =0;
	r=0;
	for(int ini=0;ini<n;){
	
		if(r==n)break;
		if(in>=k){
			while(ini<n && s[ini]=='L')ini++;
			while(ini<n && s[ini]=='R'){
				ini++;
			}
			in--;
		}
		while(in<k && r<n){
		while(r<n && s[r]=='L'){
			r++;
		}
		if(in<k){
			in++;
			while(r<n && s[r]=='R'){
			   r++;
			}
		}
		}
		
		while(r<n && s[r]=='L')r++;
		if(r==n){
		best = max(best,r-ini-1 + pre[ini-1+1] + pre[n] - pre[r]);
		break;
		}
			best = max(best,r-ini-1 + pre[ini-1+1] + pre[n] - pre[r]);	
	}
	cout<<best<<endl;
			 		
}

Measured memory_bytes: 896
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int i,l[101],j,n,flg;
	char w[101][11],a[101],b[101];
	cin>>n;
	flg=0;
	for(i=0;i<n;i++) cin>>w[i];
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
		
//			cout<<i<<endl;
//			cout<<w[i]<<endl;
//			cout<<j<<endl;
//			cout<<w[j]<<endl;
			
			if(strcmp(w[i],w[j])==0){
//				cout<<"check"<<endl;
				flg=1;
			}
//			cout<<flg<<endl;
		}
	}
	
//	cout<<flg<<endl;
	
	for(i=0;i<n;i++) l[i]=strlen(w[i]);
	for(i=0;i<n-1;i++){
		if(w[i][l[i]-1]!=w[i+1][0]) flg=1;
//		cout<<w[i][l[i]-1]<<endl;
//		cout<<w[i+1][0]<<endl;
//		cout<<flg<<endl;
	}
	
//	cout<<flg<<endl;
	
	if(flg==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


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

int main(){
int x,N,i,a;
x=0;
a=0;
scanf("%d",&N);
char S[N+1];
scanf("%s",S);
if(N!=0){

for(i=1;i<=N;i++){
if(S[i-1]=='I'){
x=x+1;
}
else{
x=x-1;
}
if(x>a){
a =x;
}
}
}
printf("%d",a);
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////	
	string s;
	cin >> s;
	vector<char> v;
	SREP(i,s){
		if(s[i]=='0'){
			v.push_back('0');
		}else if(s[i]=='1'){
			v.push_back('1');
		}else if(s[i]=='B'){
			if(v.size()!=0) v.pop_back();
		}
	}
	SREP(i,v) cout << v[i];
	cout << endl;
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    string s; cin>>s;
    bool ok[2]={};
    int x=s[0]-'0', y=s[1]-'0';
    if(x*10+y>=1 && x*10+y<=12){
        ok[0]=1;
    }
    x=s[2]-'0', y=s[3]-'0';
    if(x*10+y>=1 && x*10+y<=12){
        ok[1]=1;
    }
    if(ok[0] && ok[1]) cout<<"AMBIGUOUS"<<endl;
    else if(ok[0] && !ok[1]) cout<<"MMYY"<<endl;
    else if(!ok[0] && ok[1]) cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
    return 0;
}

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

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<long long> arr(a);
	vector<long long> brr(b);
	vector<long long> crr(c);
	for(long long i=0;i<a;i++)
		cin>>arr[i];
	for(long long i=0;i<b;i++)
		cin>>brr[i];
	for(long long i=0;i<c;i++)
		cin>>crr[i];
	sort(arr.rbegin(),arr.rend());
	sort(brr.rbegin(),brr.rend());
	for(long long i=0;i<x;i++)
		crr.push_back(arr[i]);
	for(long long i=0;i<y;i++)
		crr.push_back(brr[i]);
	long long ans=0;
	sort(crr.rbegin(),crr.rend());
	for(long long i=0;i<x+y;i++)
		ans+=crr[i];
	cout<<ans;

	return 0;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, x, y;
  cin >> a >> b >> x >> y;
  if (a*b < x*y) {
    cout << x*y << endl;
  }
  if (a*b > x*y) {
    cout << a*b << endl;
  }
  if (a*b == x*y) {
    cout << a*b << endl;
  }
}

Measured memory_bytes: 3588
n,q = map(int, input().split())
a = []
t = 0
for i in range(n):
    a.append(input().split())
 
while len(a) != 0:
    proc =  a.pop(0)
    if int(proc[1]) <= q:
        t += int(proc[1])
        print(proc[0],t)
    else:
        t += q
        proc[1] = int(proc[1]) - q
        a.append(proc)


Measured memory_bytes: 17120
a=input()
b=input()
s=[]
if len(a)==len(b):
    for i in range(len(a)):
        s.append(a[i])
        s.append(b[i])
else:
    for i in range(len(b)):
        s.append(a[i])
        s.append(b[i])
    s.append(a[-1])
print("".join(s))

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

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

int color[205];
int dist;
int d[205][205];
vector<vector<int>>g;
int n;

bool dfs(int v,int c){
    color[v]=c;
    for(auto x:g[v]){
        if(color[x]==c)return false;
        if(color[x]==0&&!dfs(x,-c))return false;
    }
    return true;
}

//ワーシャルフロイド法、全点対最短路
const int INFTY=100000;

void warshall_floyd(int V){//Vは頂点数
	for(int k=0;k<V;++k){//経由する頂点
		for(int i=0;i<V;++i){//始点となる頂点
			for(int j=0;j<V;++j){
                //目的地の頂点
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
		}
	}
}


void solve(){
    cin>>n;
    vector<string>t(n);
    vector<vector<int>>s(n,vector<int>(n));
    g.resize(n);
    rep(i,n){
        cin>>t[i];
        rep(j,n){
            s[i][j]=t[i][j]-'0';
            if(s[i][j])g[i].pb(j);
        }
    }
    rep(i,n){
        if(color[i]==0){
            if(!dfs(i,1)){
                cout<<-1<<"\n";
                return;
            }
        }
    }
    rep(i,n){
        rep(j,n)if(s[i][j])d[i][j]=1;
        else {
            if(i!=j)d[i][j]=INFTY;
        }
    }
    warshall_floyd(n);
    rep(i,n)rep(j,n)if(d[i][j]<INF)dist=max(dist,d[i][j]);
    cout<<dist+1<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 768
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var numbers = input[0].split(' ');

    if (numbers[0] == numbers[1]) {
        console.log(numbers[2]);
    }
    else if (numbers[0] == numbers[2]) {
        console.log(numbers[1]);
    }
    else {
        console.log(numbers[0]);
    }

    return 0;
}


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

typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
  
ll a;
ll ans=0;

int main(){
    cin>>a;
    rep(i,1,a+1){
        if(i%3==0||i%5==0)continue;
      	ans+=i;
    }
    //for使わないとき//1~15 3,6,9,12,15,5,10
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
n, m = map(int, input().split())

A=[input() for _ in range(n)]
B=[input() for _ in range(m)]

#shift回数, 1軸
num = n - m + 1

#基本はNoとして一致するのものがあればYESを表示させる
check = 'No'

#起点の設定
for i in range(num):
    for j in range(num):
        C = []
        #要素の追加
        for k in range(m):
            #CにAからM*Mで抜き出した配列を作る
            C.append(A[i+k][j:j+m])
        #Bと抜き出したCを比較して一致したらYESにしてループも抜ける
        if C == B:
            check = 'Yes'
            break
print(check)


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N;
ll a[110];
ll ans;
int main() {
    cin>>N;
    REP(i,0,N){
        cin>>a[i];
    }
    REP(i,1,N){
        if(a[i]==a[i-1]){
            a[i]=inf;
            ans++;
        }
    }
    p(ans);
    return 0;
}

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

using namespace std;

int arr[103];

int main()
{
  int n;
  cin >> n;
  for(int i=1;i<=n;i++)cin >> arr[i];
  for(int i=1;i<=n;i++)
  {
    if(arr[i]%2==0 and arr[i]%3!=0 and arr[i]%5!=0)
    {
      cout << "DENIED";
      return 0;
    }
  }
  cout << "APPROVED";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
typedef long long ll; 
ll dp[300005], dp_l[300005], dp_r[300005];
ll sum[300005], ans[300005], tmp[300005]; 
int val[300005], que[300005]; 
inline ll calc(ll *arr, int x, int y)
{
	ll a = arr[x] - sum[x] + (ll)x * (x - 1) / 2, b = arr[y] - sum[y] + (ll)y * (y - 1) / 2; 
	ll res = (b - a) / (y - x) + (bool)((b - a) % (y - x)); 
	return std::max(res, (ll)y + 1); 
}
inline void dynamic_programming(int n)
{
	dp[0] = 0; 
	int he = 0, ta = 0; 
	que[0] = 0; 
	for (int i = 1; i <= n; i++)
	{
		while (he < ta && calc(dp, que[ta - 1], que[ta]) <= i)
			ta--; 
		int pos = que[ta]; 
		dp[i] = std::max(dp[i - 1], dp[pos] + (ll)(i - pos) * (i - pos + 1) / 2 + sum[i] - sum[pos]); 
		while (he < ta && calc(dp, que[ta - 1], que[ta]) <= calc(dp, que[ta], i))
			ta--;
		que[++ta] = i; 
	}
}
void work(int l, int r, int coef)
{
	if (l == r)
	{
		dp[l] = std::max(dp[l], val[l] + dp_l[l - 1] + dp_r[l + 1] + 1); 
		return; 
	}
	int m = l + r + coef >> 1, he = 0, ta = -1; 
	for (int i = l - 1; i < m; i++)
	{
		while (he < ta && calc(dp_l, que[ta - 1], que[ta]) <= calc(dp_l, que[ta], i))
			ta--;
		que[++ta] = i; 
	}
	for (int i = m + 1; i <= r; i++)
	{
		while (he < ta && calc(dp_l, que[ta - 1], que[ta]) <= i)
			ta--; 
		int pos = que[ta]; 
		tmp[i] = dp_l[pos] + (ll)(i - pos) * (i - pos + 1) / 2 + sum[i] - sum[pos] + dp_r[i + 1]; 
	}
	for (int i = r; i > m; i--)
	{
		if (i != r)
			tmp[i] = std::max(tmp[i], tmp[i + 1]); 
		dp[i] = std::max(dp[i], tmp[i]);
	} 
	work(l, m, coef);
	work(m + 1, r, coef); 
}
int main()
{
	// freopen("ARC066-F.in", "r", stdin); 
	int n, q; 
	scanf("%d", &n); 
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", val + i); 
		val[i] *= -1; 
		sum[i] = sum[i - 1] + val[i]; 
	}
	dynamic_programming(n); 
	memcpy(dp_l, dp, sizeof(dp)); 
	std::reverse(val + 1, val + n + 1); 
	for (int i = 1; i <= n; i++)
		sum[i] = sum[i - 1] + val[i]; 
	dynamic_programming(n); 
	memcpy(dp_r, dp, sizeof(dp)); 
	std::reverse(dp_r + 1, dp_r + n + 1); 
	memset(dp, -0x3f, sizeof(dp)); 
	std::reverse(val + 1, val + n + 1); 
	for (int i = 1; i <= n; i++)
		sum[i] = sum[i - 1] + val[i]; 
	work(1, n, 0); 
	memcpy(ans, dp, sizeof(dp)); 
	memset(dp, -0x3f, sizeof(dp)); 
	std::reverse(val + 1, val + n + 1); 
	for (int i = 1; i <= n; i++)
		sum[i] = sum[i - 1] + val[i]; 
	for (int i = 0; i <= n + 1; i++)
		std::swap(dp_l[i], dp_r[n - i + 1]); 
	work(1, n, -1); 
	for (int i = 1; i <= n; i++)
		ans[i] = std::max(ans[i], dp[n - i + 1]); 
	std::reverse(val + 1, val + n + 1); 
	for (int i = 0; i <= n + 1; i++)
		std::swap(dp_l[i], dp_r[n - i + 1]); 
	scanf("%d", &q); 
	while (q--)
	{
		int pos, x; 
		scanf("%d%d", &pos, &x); 
		printf("%lld\n", std::max(dp_l[pos - 1] + dp_r[pos + 1], ans[pos] - x - val[pos]));
	}
	return 0; 
}


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

int main(){
  int n;
  cin >> n;
  vector<int>x(n), xs;
  for(int i=0; i<n; i++)cin >> x[i];
  xs = x;
  sort(xs.begin(), xs.end());
  for(int i=0; i<n; i++){
    if(x[i]<=xs[n/2-1])cout << xs[n/2] << endl;
    else cout << xs[n/2-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
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;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

// I'm trying to ~~~
int main(){
    string s; cin >> s;
    s[3]='8';
    cout << s << endl;
    
}



Measured memory_bytes: 256
#include<stdio.h>

int search(int s[], int n, int key)
{
   int i = 0;
   s[n] = key;
   while(s[i] != key){
      i++;
   }

   return i != n;
}

int main()
{
   int n, q, i;
   int key = 0;
   int count = 0;
   int s[10000];

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

   for(i = 0; i < n; i++){
      scanf("%d", &s[i]);
   }

   scanf("%d\n", &q);

   for(i = 0; i < q; i++){
      scanf("%d", &key);
      if(search(s, n, key)){
         count++;
      }
   }

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

   return 0;
}


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

using namespace std;

int main() {
   int n;
   string s;
   int ans=3000000;
   cin>>n>>s;
   vector<int> a,b;
   a=vector<int>(n,0);
   b=vector<int>(n,0);
   for(int i=0;i<n;i++){
       if(i==0){
           if(s[i]=='W')a[i]+=1;
           if(s[n-i-1]=='E')b[i]+=1;
           continue;
       }
       a[i]=a[i-1]+(s[i]=='W'?1:0);
       b[i]=b[i-1]+(s[n-i-1]=='E'?1:0);
   }
    for(int i=0;i<n;i++){
       ans=min(ans,a[i]+b[n-i-1]);
   }
   cout<<ans-1<<endl;
    return 0;
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

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

using ll=long long;
#define int ll

#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>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n,m;cin>>n>>m;
	string s;cin>>s;
	vvc<int> g(n);
	rep(_,m){
		int a,b;cin>>a>>b;
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	vc<array<int,2>> d(n);
	rep(i,n){
		for(auto j:g[i])
			d[i][s[j]-'A']++;
	}
	int rem=n;
	queue<int> q;
	rep(i,n){
		if(!d[i][0]||!d[i][1])
			q.push(i);
	}
	while(q.size()){
		int v=q.front();q.pop();
		rem--;
		int k=s[v]-'A';
		for(auto f:g[v]){
			if(--d[f][k]==0&&d[f][k^1])
				q.push(f);
		}
	}
	
	cout<<(rem?"Yes":"No")<<endl;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a-c) <= d) cout << "Yes" << endl;
  else if(abs(a-b) <= d) {
    if(abs(c-b) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
 
#define MAXN 120
#define MAXV 100020
#define INF 110000000001
 
long long N,W;
long long w[MAXN],v[MAXN];
 
long long dp[MAXN][MAXV];
 
int main() {
  cin >> N >> W;
  for (long long i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  for (long long i = 0; i < N; i++) {
    for (long long  j = 0; j < MAXV; j++) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  dp[0][v[0]] = w[0];
  for (long long i = 1; i < N; i++) {
	for (long long j = 0; j < MAXV; j++) {
      if (v[i] > j) {
        if (dp[i-1][j] == INF) {
        } else {
			dp[i][j] = dp[i-1][j];
        }
      } else {
        if (dp[i-1][j] != INF && dp[i-1][j-v[i]] != INF) {
          dp[i][j] = min(w[i]+dp[i-1][j-v[i]],dp[i-1][j]);
        } else if (dp[i-1][j] != INF) {
          dp[i][j] = dp[i-1][j];
        } else if (dp[i-1][j-v[i]] != INF) {
          dp[i][j] = dp[i-1][j-v[i]] + w[i];
        } 
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i < MAXV; i++) {
    if (dp[N-1][i] <= W) ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 80128
import java.util.*;
import java.awt.*;
import java.math.BigInteger;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int k=sc.nextInt();
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= m; j++) {
                if(m*i+n*j-i*j*2==k){
                    out.println("Yes");
                    exit(0);
                }
            }
        }
        out.println("No");
    }
}

Measured memory_bytes: 22740
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        boolean flag = false;
        int n = sc.nextInt();
        char[] a = new char[n];
        char[] b = new char[n];
        int bi = 0;
        int ai = 0;
        for (int i = 0; i < n; i++) {
            int q = sc.nextInt();
            if(q == 1){
                flag = !flag;
            }else if(q == 2){
                int t = sc.nextInt();
                char c = sc.next().charAt(0);
                if(t == 1 && flag || t== 2 && !flag){
                    b[bi] = c;
                    bi ++;
                }else {
                    a[ai] = c;
                    ai ++;
                }
            }
        }
        if(flag){
            for (int i = bi - 1; i >= 0; i--) {
                System.out.print(b[i]);
            }
            for (int i = s.length() - 1; i >= 0; i--) {
                System.out.print(s.charAt(i));
            }
            for (int i = 0; i < ai; i++) {
                System.out.print(a[i]);
            }
        }else{
            for (int i = ai - 1; i >= 0; i--) {
                System.out.print(a[i]);
            }
            System.out.print(s);
            for (int i = 0; i < bi; i++) {
                System.out.print(b[i]);
            }
        }
    }
}

Measured memory_bytes: 139140
from collections import defaultdict


def solve2(s):
    ans = 0
    for i, c in enumerate(s):
        if c in '02468':
            ans += i + 1
    return ans


def solve5(s):
    ans = 0
    for i, c in enumerate(s):
        if c in '05':
            ans += i + 1
    return ans


def solve_other(s, p):
    reminders = defaultdict(lambda: 0)
    tmp = 0
    mul = 1
    for c in s[::-1]:
        c = int(c)
        tmp = (tmp + c * mul) % p
        mul = mul * 10 % p
        reminders[tmp] += 1
    reminders[0] += 1
    ans = 0
    for r, cnt in reminders.items():
        ans += cnt * (cnt - 1) // 2
    return ans


n, p = list(map(int, input().split()))
s = input()
if p == 2:
    print(solve2(s))
elif p == 5:
    print(solve5(s))
else:
    print(solve_other(s, p))


Measured memory_bytes: 4572
#A
"""
H, W = map(int, input().split())
h, w = map(int, input().split())
print(H*W-h*W-w*H+h*w)
"""
#B
"""
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
ansb = 0
for i in range(n):
    ans = 0
    a = list(map(int, input().split()))
    for k in range(m):
        ans += a[k]*b[k]
    ans += c
    if ans > 0:
        ansb += 1
print(ansb)
"""
#C
n, m = map(int, input().split())
ans = []
ansnum = 0
honsuu = 0
for i in range(n):
    a = list(map(int, input().split()))
    ans.append(a)
ans.sort()
for i in ans:
    if honsuu + i[1] <= m:
        ansnum += i[0] * i[1]
        honsuu += i[1]
    else:
        ansnum += (m - honsuu) * i[0]
        break

print(ansnum)
#D

Measured memory_bytes: 60760
N=int(input())
L = [int(i) for i in input().split()]
ans=0
for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
        continue
      x,y,z=sorted([L[i],L[j],L[k]])
      if x + y > z:
        ans += 1
print(ans)


Measured memory_bytes: 68520
#include<cmath>
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
#define ll long long
#define MOD 10000000
ll read(){
	ll x=0,w=1;
	char ch=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')
			w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return w*x;
}//快读算法
const long N = 200000;//这相当与存了200000个素数
long prime[N] = {0},num_prime = 0;//假设都是素数
int isNotPrime[N] = {1, 1};//先将0，1排除   不是素数
void SE(){
	for(long i = 2 ; i < N ; i ++){
        if(! isNotPrime[i])//isNotPrime==0
            prime[num_prime ++]=i;//自己在前面打好了标记。 //关键处1           /*i为合数时也要参与循环*/
		for(long j = 0 ; j < num_prime/*小于已经求出的质数个数*/ && i * prime[j]/*乘以其它质数，且质数比自己小或者是自己（已经求出来了），所以不可能重复*/ <  N ; j ++){
                isNotPrime[i * prime[j]] = 1;//乘以其它素数得到的一定是合数，之所以不重复是因为质数间不等
            if( !(i % prime[j] ) )  //关键处2 i%prime==0  根据“关键处2”的定义，当p1==prime[j] 的时候，
            //筛除就终止了(从最小质数开始所以本句话成立），
                break;
        }
    }
}//这是欧拉筛的算法，其中 prime[N]中储存的是前  N  个素数

int QuickPow(int x,int N){
    int res = x;
    int ans = 1;
    while(N){
        if(N&1){
            ans = ans * res;
        }
        res = res*res;
        N = N>>1;
    }
    return ans;
}//快速求解  x^n  的值---快速幂
const int M=2;
struct Ma{
    int a[M][M];
    Ma(){
        memset(a,0,sizeof(a));
    }
    void unit(){
        a[0][0]=a[1][1]=1;
        a[0][1]=a[1][0]=1;
    }
    Ma operator *(const Ma &B)const{
        Ma ans;
        for(int i=0;i<M;i++){
            for(int j=0;j<M;j++){
                for(int k=0;k<M;k++){
                    ans.a[i][j]+=a[i][k]*B.a[k][j];
                }
            }
        }
        return ans;
    }
    Ma operator^(int n) const{
        Ma ans;ans.unit();
        Ma A=*this;
        while(n){
            if(n&1){
                ans=ans*A;
                A=A*A;
                n>>1;
            }
        }
        return ans;
    }
    void show(){
        cout<<"矩阵"<<endl;
        for(int i=0;i<M;i++){
            for(int j=0;j<M;j++){
                cout<<a[i][j]<<" ";
            }
            cout<<endl;
        }
    }
};
int main(){
	int N,M;
	cin>>N>>M;//代表一共有几道题，还有共作答了几次。
	bool ac[105000];
	int wa[105000]={0};
	for(int i=0;i<=M;i++){
        ac[i]=false;
        wa[i]=0;
	}
	int a;
	string b;
	int numwa=0;
	int numac=0;
	for(int i=0;i<M;i++){
        cin>>a>>b;
        if(ac[a]) continue;
        if(b=="AC"){
            ac[a]=true;
            numac++;
            numwa=numwa+wa[a];
        }else if(b=="WA"){
            wa[a]++;
        }
	}
	cout<<numac<<" "<<numwa<<endl;
	return 0;
}









Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}

map<ll, int> res;
void factorization(ll N) {
  if(N == 1 || N == 0) return;
  ll n = N;
  ll i = 2;
  while(n >= i * i) {
    while(n % i == 0) {
      if(res.count(i)) res[i]++;
      else res[i] = 1;
      n /= i;
    }
    i++;
  }
  if(n != 1) res[n] = 1;
}

int main() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);
  factorization(g);
  cout << res.size()+1 << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  static int[][] bulbs;
  static int[] p;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();

    bulbs = new int[m][0];
    p = new int[m];

    for (int i = 0; i < m; ++i) {
      int k = sc.nextInt();
      bulbs[i] = new int[k];

      for (int j = 0; j < k; ++j) {
        int s = sc.nextInt();
        bulbs[i][j] = s;
      }
    }

    for (int i = 0; i < m; ++i) {
      p[i] = sc.nextInt();
    }

    System.out.println(combinations(new int[n], n));
  }

  public static int combinations(int[] combination, int switchN) {
    if (switchN > 0) {
      int[] combination1 = combination.clone();
      combination[switchN - 1] = 0;
      combination1[switchN - 1] = 1;
      return combinations(combination, switchN - 1) + combinations(combination1, switchN - 1);
    }
    return checkSwitches(combination) ? 1 : 0;
  }

  public static boolean checkSwitches(int[] combination) {
    boolean res = true;
    for (int j = 0; j < bulbs.length; ++j) {
      int sum = 0;
      for (int i : bulbs[j])
        sum += combination[i - 1];
      res &= sum % 2 == p[j];
    }
    return res;
  }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin>>a>>b;
    
    cout1(b+(b-a))
}

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

int main(){
    int a, b, tmp;
    
    while(1){
        cin >> a >> b;
        
        if(a == 0 && b == 0) break;
        
        if(a > b){
            tmp = a;
            a = b;
            b = tmp;
        }
        cout << a << " " << b << endl;
    }
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define     FasterIO        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define     watch(a)        cout<<fixed<<setprecision(a)
#define     lp(i,a,b)       for(int i=a;i<b;i++)
#define     Endl            "\n";
#define     tab             "\t"
#define     reset(a,b)      memset(a,b,sizeof(a));
#define     sfl(a)          scanf(" %lld", &a);
#define     sf(a)           scanf(" %d", &a);
#define     srt(a)          sort(a.begin(),a.end());
#define     pi              2*acos(0.0)
const int sz=1e6+9;
const ll inf=1e18L+9;
ll dp[sz];


void solve(){
    reset(dp,inf);
    int n,w;
    sf(n);
    sf(w);
    vector<pair<ll,int>>v(n);
    dp[0]=0;
    int pnt=0;
    lp(i,0,n){
       sfl(v[i].first);
       sf(v[i].second);
       pnt+=v[i].second;
    }
    //bug(pnt, 1);
   // sort(v.begin(),v.end(),com);
    for(int i=0;i<n;i++){

        for(int j=pnt-v[i].second;j>=0;j--){
            dp[j+v[i].second]=min( dp[j+v[i].second],(ll)dp[j]+(ll)v[i].first);
        }

    }
   // bug("140 dp",dp[140]);
    for(int i=pnt;i>=0;i--){
        if(dp[i]<=w){
            printf("%d\n",i);
            return;
        }
    }
}

int main(){
    //FasterIO;
//    #ifndef ONLINE_JUDGE
 //       freopen("1.txt","r",stdin);
//    #endif
    //int t;
//cin>>t;
   // while(t--)
        solve();
}


Measured memory_bytes: 8064
#include <stdio.h>
#include <string.h>
int main(void){
    char s[10+5];
    scanf("%s", s);
    for(int i=0; i<strlen(s); i++){
        if(s[i]=='B'){
            for(int j=i-1; j>=0; j--){
                if(s[j]=='0'|| s[j]=='1'){
                    s[j]='B';
                    break;
                }
            }
        }
    }
    for(int i=0; i<strlen(s); i++){
        if(s[i]!='B')printf("%c", s[i]);
    }
}


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

int main(){
  long long N; 
  cin >> N;
  vector<string> result(N);
  for (int i = 0; i < N; i++){
    cin >> result[i];
  }
  
  int countac = 0, countwa = 0, counttle = 0, countre = 0;
  for (int i = 0; i < N; i++){
    if (result[i] == "AC"){
      countac++;
    }
    else if (result[i] == "WA"){
      countwa++;
    }
    else if (result[i] == "TLE"){
      counttle++;
    }
    else if (result[i] == "RE"){
      countre++;
    }
  }
  
  cout << "AC x " << countac << endl;
  cout << "WA x " << countwa << endl;
  cout << "TLE x " << counttle << endl;
  cout << "RE x " << countre << endl;
}

Measured memory_bytes: 6308
#include <bits/stdc++.h>
    //#define int long long
    typedef long long ll;
    #define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
    #define forn(i, n) fore(i, 0, n)
    #define fori(i, l, r) fore(i, l, (r) + 1)
    #define sz(v) int((v).size())
    #define all(v) (v).begin(), (v).end()
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    using namespace std; 
     
    const double PI = atan(1)*4;

    int dx[8]={1,0,-1,0,1,-1,-1,1};
    int dy[8]={0,1,0,-1,1,1,-1,-1};
     
     
    bool isprime(int n)
    {
        for(int i=2;i*i<=n;i++)
            if(n%i==0)
                return false;
        return true;
    }

    const int mod = 998244353;
     
    bool comp(pair<int,int> a, pair<int,int> b)
    {
        return b.ff < a.ff ;
    }
     
    ll pw(ll b, ll e)
    {
        ll ans = 1;
        while(e)
        {
            if(e & 1)
                ans = (ans * b) % mod;
            b = (b * b) % mod;
            e >>= 1;
        }
        return ans;
    }

    ll fact[200002], inv[200002];
    
    ll C(ll n, ll k)
    {
        return ((((fact[n] * inv[k]) % mod) * inv[n-k]) % mod);
    }
     
    /*void bsearch(int max,int min)   //  for function 
    //void bsearch(int a,int n, int x)     // for array
    {
        int k=min;
     
        //  for array
     
    /*    for(int b=n/2; b>=1; b/=2)
        {
            while(k+b<n && arr[k+b]<=x) k+=b; 
        }
     
        if(arr[k]==x)
            cout<<"found at "<<k+1;
        else
            cout<<"not found";
    */
     
        //  for function 
     
    /*    for(int b=max; b>=1; b/=2)
        {
            while( !fn(b+k) ) k+=b;
        }
        cout<<k+1;
     
    }*/
     
    int vis[200005];
     
    int main()
    {
        int t=1;
        //cin>>t;
     
        while(t--)
        {
            int n,k;
            cin>>n>>k;

            int a[n];
            forn(i,n) cin>>a[i];

            int dp[n+1]={0};

            dp[1]=abs(a[1]-a[0]);
            fore(i,2,n)
            {
                int mn=INT_MAX;
                fori(j,1,k)
                {
                    if(i-j<0)
                        break;
                       
                    mn=min(mn , dp[i-j] + abs(a[i] - a[i-j])) ;
                }
                dp[i]=mn;
            }

            cout<<dp[n-1];
        }
        return 0;
    }

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

#define INT 810114514

vector<pair<int,int>> e[114514];
bool flag=true;

void dfs(int);
bool al[114514]={};
int x[114514];

int main(){
    int N,M;
    int L,R,D;
    cin >> N >> M;
    REP(i,M){
        cin >> L >> R >> D;
        e[L].push_back({R,D});
        e[R].push_back({L,-D});
    }
    REP(i,N+1){
        if(i==0)continue;
        if(!al[i])dfs(i);
        if(flag==false)break;
    }
    if(flag==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

void dfs(int g){
    al[g]=1;
    REP(i,e[g].size()){
        if(al[e[g][i].first]==1){
            if(x[e[g][i].first] - x[g] != e[g][i].second){
                flag=false;break;
            }
        }else{
            x[e[g][i].first]=x[g]+e[g][i].second;
            dfs(e[g][i].first);
        }
    }
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n; cin >> n;
    if(n<10) cout << n << endl;
    else if(n < 100) cout << 9 << endl;
    else if(n < 1000) cout << n - 99 + 9 << endl;
    else if(n < 10000) cout << 9 + 900 << endl;
    else if(n < 100000) cout << 9 + 900 + n - 9999 << endl;
    else cout << 9 + 900 + 90000 << endl;
}

Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef complex < double > com;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test() {
    ll n;
    cin >> n;
    pll p[n];
    for (ll i = 0, x, l; i < n; ++i) {
        cin >> x >> l;
        p[i] = {x + l, x - l};
    }
    sort(p, p + n);
    ll ans = n;
    ll cur = p[0].F;
    for (int i = 1; i < n; ++i) {
        if (p[i].S >= cur) {
            cur = p[i].F;
        } else {
            --ans;
        }
    }
    cout << ans << "\n";
}

int main() {
    fast_io();
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cout << fixed << setprecision(15);
    test();
    #ifdef HOME
        cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
    #endif
    return 0;
}


Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>l(n),r(n);
  rep(i,0,n)cin>>l[i]>>r[i];
  vector<ll>order(n);
  iota(ALL(order),0);
  sort(ALL(order),[&](ll x,ll y){
    return l[x]+r[x]>l[y]+r[y];
  });
  vector<vector<ll>>dp(n+1);
  vector<vector<ll>>dp2(n+1);
  dp[0].assign(1,0);
  dp2[0].assign(1,INF);
  //j,左に寄せた個数
  rep(i,0,n){
    dp[i+1].assign(i+2,INF);
    dp2[i+1].assign(i+2,INF);
    ll idx=order[i];
    ll len=l[idx]+r[idx];
    rep(j,0,i+1){
      chmin(dp[i+1][j+1],dp[i][j]+len*j+r[idx]);
      chmin(dp[i+1][j],dp[i][j]+len*(i-j)+l[idx]);
      chmin(dp2[i+1][j],dp[i][j]+len*(n/2));
      chmin(dp2[i+1][j+1],dp2[i][j]+len*j+r[idx]);
      if(i-j-1>=0)chmin(dp2[i+1][j],dp2[i][j]+len*(i-j-1)+l[idx]);
    }
  }
  //debug(dp,n+1,n+1);
  if(~n&1)cout<<dp[n][n/2]<<endl;
  else cout<<dp2[n][n/2]<<endl;
  return 0;
}

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

int main() {
    using namespace std;
    int i, j, k, A[3][3], n, B[10];
    bool a[3][3];
    string ans;

    for(i=0; i<3; i++){
        for(j=0; j<3; j++){
            cin >> A[i][j];
        }
    }
    cin >> n;
    for(i=0; i<n; i++){
        cin >> B[i];
    }

    for(i=0; i<3; i++){
        for(j=0; j<3; j++){
            a[i][j] = false;
            for(k=0; k<n; k++) {
                if(B[k] == A[i][j]){
                    a[i][j] = true;
                }
            }
        }
    }
    ans = "No";
    for(i=0; i<3; i++){
        if(a[i][0] and a[i][1] and a[i][2]){
            ans = "Yes";
        }
    }
    for(i=0; i<3; i++){
        if(a[0][i] and a[1][i] and a[2][i]){
            ans = "Yes";
        }
    }
    if(a[0][0] and a[1][1] and a[2][2]) ans = "Yes";
    if(a[0][2] and a[1][1] and a[2][0]) ans = "Yes";
    cout << ans;
}

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

int main() {
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    string out = "";
    
    if(x-r < 0 || y-r < 0 || x+r > W || y+r > H){
        out = "No";
    }else{
        out = "Yes";
    }
    
    cout << out << endl;
    return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  // cout << (-9) / (-2) << endl;
  // cout << (-9) % (-2) << endl;
  // cout << (-10) / (-2) << endl;
  // cout << (-10) % (-2) << endl;
  // cout << (9) / (-2) << endl;
  // cout << (9) % (-2) << endl;
  // cout << (-9) / (2) << endl;
  // cout << (-9) % (2) << endl;

  int n;
  cin>>n;
  vector<int> ans;
  if(n == 0){
    cout << 0 << endl;
    return 0;
  }
    
  while(n != 1) {
    int q = n / (-2);
    int r = n % (-2);
    if(r == -1) {
      r = 1;
      q = (n - r) / (-2);
    }
    n = q;
    ans.push_back(r);
  }
  cout << 1;
  for(int i = ans.size() - 1; i >= 0; i--)
  {
    cout << ans[i];
  }
  cout << endl;
  

  return 0;
}


Measured memory_bytes: 256
module mymodule
  implicit none
  public
  type store_type
    integer(8) :: price, storage
  end type store_type
end module mymodule

program main
  use mymodule
  implicit none
  integer(8) :: n, m, i, cost
  type(store_type), allocatable :: stores(:)

  read (*, *) n, m
  allocate (stores(n))
  do i = 1, n
    read (*, *) stores(i) % price, stores(i) % storage
  end do

  call quicksort(stores)

  cost = 0
  do i = 1, n
    if (m <= stores(i) % storage) then
      cost = cost + m * stores(i) % price
      exit
    end if
    cost = cost + stores(i) % storage * stores(i) % price
    m = m - stores(i) % storage
  end do

  write (*, "(i0)") cost

  contains

  recursive subroutine quicksort(a)
    type(store_type), intent(inout) :: a(:)
    type(store_type) :: pivot, tmp
    integer :: i, j, k, n
    real(4) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (pivot % price > a(i) % price)  ! Derived type comparison
        i = i + 1
      end do
      do while (a(j) % price > pivot % price)  ! Derived type comparison
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort
end program main


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

int main(void){
  int n;
  string s,ans;
  cin >> n;
  cin >> s;
  ans = s;
  vector<bool> clears(n, false);
  map<char, int> runShortCount;
  for(int i=0;i<n;++i){
    if(s[i] == '(' && !clears[i]){
      for(int j=i;j<n;++j){
        if(s[j] == ')' && !clears[j]){
          clears[i] = true;
          clears[j] = true;
          break;
        }
      }
    }
  }
  for(int i=0;i<n;++i){
    if(!clears[i]){
      if(s[i] == '('){
        ans = ans+')';
      }
      else if(s[i] == ')'){
        ans = '(' + ans;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int64_t k=0, n=0;
  cin >> k >> n;
  int64_t m=0;
  int64_t j=0;
  int64_t l=0, o=0;
  for(int i=0; i<n; i++){
    int64_t a;
    cin >> a;
    if(i==0)l=a;
    if(i==n-1)o=a;
    m=max(a-j, m);
    //cout << m <<endl;
    j=a;
  }
  //cout << l << " " << o << endl;
  m=max(m,k-o+l);
  cout << k-m << endl;
}


Measured memory_bytes: 256