akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h> using namespace std;
#include<iostream>
using namespace std;
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<stack>
#include<queue> //priority_queue inside queue
#include<deque>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
typedef long long ll;
typedef unsigned long long ull;
#define f(i,start,end) for(i=start;i<=end;i++)
#define min_heap priority_queue<int, vector<int>, greater<int> >
#define max_heap priority_queue<int>

bool isPrime(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        if(n%i==0) return false;
    }
    return true;
} //returns true if prime!


int main()
{
fast;
//int t=0,tc=0; cin >> tc; f(t,1,tc) //testcases
{
   int i=0, j=0, k=0, n=0, tmp=0;
   string s,t; cin >> s >> t;
   t.erase(t.end()-1);
   if(s==t) cout << "Yes";
   else cout << "No";
}
return 0;
}
    

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int a,b;cin >> a >> b;
  int x=0,y=0;
  for(int i = 0; i < n; ++i){
    int p; cin >> p;
    x += p > a;
    y += p > b;
  }
  cout << min({n-x,x-y,y}) << endl;
}

Measured memory_bytes: 3580
#include<stdio.h>
#include<math.h>
#include <string.h>


int main() {
	int i, j, k;
	long long int l = 0;
	int m, g = 0, n, q, b;
	int f = 0;
	int a[5][5];


	scanf("%d %d %d", &a[1][1], &a[1][2], &a[1][3]);
	scanf("%d %d %d", &a[2][1], &a[2][2], &a[2][3]);
	scanf("%d %d %d", &a[3][1], &a[3][2], &a[3][3]);
	scanf("%d", &n);
	for (i = 0;i < n;i++) {
		scanf("%d", &b);
		for (j = 1;j < 4;j++) {
			for (k = 1;k < 4;k++) {
				if (a[j][k] == b) {
					a[j][k] = 0;
				}
			}
		}
	}

	for (i = 1;i < 4;i++) {
		if ((a[i][1] + a[i][2] + a[i][3]) == 0) {
			f = 1;
		}
		if ((a[1][i] + a[2][i] + a[3][i]) == 0) {
			f = 1;

		}
	}
	if ((a[1][1] + a[2][2] + a[3][3]) == 0) {
		f = 1;

	}
	if ((a[1][3] + a[2][2] + a[3][1]) == 0) {
		f = 1;

	}



	if (f == 1) {
		printf("Yes");
	}
	else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    if (count(A.begin(), A.end(), 0) > 0) {
        cout << 0 << endl;
        return 0;
    }

    ll prod = 1;
    for (int i = 0; i < N; ++i) {
        if (A[i] > 1000000000000000000LL / prod) {
            cout << -1 << endl;
            return 0;
        }
        prod *= A[i];
    }
    
    cout << prod << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long INF = MOD*MOD;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k, ans;
string s;


int main(){
  cin >> n;
  int a[n]; rep(i,n) cin >> a[i];
  int b[n]; rep(i,n) cin >> b[i];
  vector<int> ama = {};
  int ans = 0; ll sum = 0;
  rep(i,n){
    if(a[i] >= b[i]) ama.push_back(a[i]-b[i]);
    else {
      sum += a[i]-b[i]; ans++;
    }
  }
  sort(ama.begin(),ama.end());
  int i = 0;
  while(sum < 0 && i < ama.size()){
    sum += ama[ama.size()-1-i]; i++; ans++;
  }
  if(sum < 0) cout << "-1\n";
  else{
    cout << ans << "\n";
  }
}

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

int main(){
  int a,b,c;
  cin >> a >> b >>c;
  int count5=0,count7=0;
  if(a == 5) count5++;
  if(b == 5) count5++;
  if(c == 5) count5++;
  if(a == 7) count7++;
  if(b == 7) count7++;
  if(c == 7) count7++;
  
  if(count5 == 2 && count7 == 1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, ans=0;
	cin >> n;

	map<string, lli> im;
	rep(i,n){
		string s;
		cin >> s;
		sort(all(s));
		if(im[s] > 0){
			ans += im[s];
			im[s] += 1;
		}else{
			im[s] = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11264
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    long a, b;
    cin >> n >> a >> b;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    vector<int> r(n);
    for (int i = 0; i < n; i++) {
        r[p[i]] = i;
    }
    vector<vector<long>> d(n + 1, vector<long>(n, MAX_LONG));
    d[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (d[i][j] == MAX_LONG) continue;
//            cout << i << " " << j << " " << d[i][j] << "\n";
            int jj = std::max(j, r[i]);
//            cout << "-> " << i + 1 << " " << jj << " " << d[i][j] + a << "\n";
            d[i + 1][jj] = std::min(d[i + 1][jj], d[i][j] + a);
            if (j <= r[i]) {
                d[i + 1][jj] = std::min(d[i + 1][jj], d[i][j]);
//                cout << "-> " << i + 1 << " " << jj << " " << d[i][j] << "\n";
                d[i + 1][j] = std::min(d[i + 1][j], d[i][j] + b);
//                cout << "-> " << i + 1 << " " << j << " " << d[i][j] + b << "\n";
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < n; j++) {
            if (d[i][j] == MAX_LONG) continue;
        }
    }
    long res = MAX_LONG;
    for (int j = 0; j < n; j++) {
        res = std::min(res, d[n][j]);
    }
    cout << res << "\n";



    return 0;
}

Measured memory_bytes: 195840
from collections import deque
n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for i in range(n)]
xh.sort()
que = deque()
ans = 0
atk = 0
for x, h in xh:
    while que and que[0][0] <= x:
        atk -= que.popleft()[1]
    h -= a*atk
    if h <= 0:
        continue
    count = -(-h//a)
    ans += count
    atk += count
    que.append((x+2*d+1, count))
print(ans)

Measured memory_bytes: 66368
S = input()

cap = S[0]
mid = list(S[2:-1])

if (mid.count('C') >= 1):
    index = S.index('C')
    strr = S[1:index] + S[index + 1 :]
else:
    print('WA')
    exit()


if (cap == 'A' and mid.count('C') == 1 and strr.islower() == True):
    print('AC')
else:
    print('WA')



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			int count = 0;
			for (int i = n + 1; i <= 2 * n; i++) {
				int num = (int) Math.sqrt(i);
				if (i == 2)	num = 2;
				int yaku_count = 0;
				for (int j = 1; j < num + 1; j++) {
					if (i % j == 0)
						yaku_count += 2;
				}
				if (yaku_count  == num * num) {
					yaku_count -= 1;
				}
				if (i == 2)
					yaku_count -= 1;
				if (yaku_count == 2) {
					count += 1;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 12000
def check(x1,x2,y1,y2):
  p1=x1
  p2=x2
  q1=y1
  q2=y2
  if x1<=x2:
    x1=p1
    x2=p2
  else:
    x1=p2
    x2=p1
  if y1<=y2:
    y1=q1
    y2=q2
  else:
    y1=q2
    y2=q1
  count=0
  for ttx,tty in xy:
    if x1<=ttx<=x2 and y1<=tty<=y2:
      count+=1
  if count>=k:
    res=True
  else:
    res=False
  return res

n,k=map(int,input().split())
x,y=[],[]
xy=[]
for i in range(n):
  a,b=map(int,input().split())
  x.append(a)
  y.append(b)
  xy.append((a,b))
from itertools import combinations
ans=10**20
for xx in combinations(x,2):
  for yy in combinations(y,2):
    if check(xx[0],xx[1],yy[0],yy[1]):
      tmp=abs(xx[0]-xx[1])*abs(yy[0]-yy[1])
      ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 77312
#include <math.h>
#include <stdio.h>
typedef long long ll;
int main() {
	ll n;
	ll ans = 0;
	scanf("%lld", &n);
	for (ll i = 2; i * i <= n; i++) {
		int cnt = 0;
		while (n % i == 0) {
			cnt++;
			n /= i;
		}
		// printf("%d\n", cnt);
		ans += (ll)(-1 + sqrt(1 + 8 * cnt)) / 2;
	}
	if (n == 1) {
		// printf("\b\b \n");
	} else {
		ans++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2156
#include<bits/stdc++.h>
using namespace std;
int main() {
 	//一回目は座標0でバウンドする。D.at(0)=0
 	int ans =0;
	//とりあえずDiを全て求めちゃう？いいね
		int n , x;
	cin >> n >> x;
	vector<int> L(n);
	for (int i = 0 ; i < n ; i++){
	  cin  >> L.at(i) ;
	  }
	 vector<int> D(n+1);
	int a=0;//aは一個前の値をみるためのへんすう
	 for(int i = 0 ; i<n+1; i++){
	   if(i==0){
	     D.at(i)=0;
	     a=D.at(i);
	     //cout <<"a:"<<a<<endl;
	     }
	     else{
	       D.at(i)=a+L.at(i-1);
	       
	       a = D.at(i);
	       //cout<<"a:"<<a<<endl;
	       }}
	      //i+1回目は、座標D.at(i)で跳ねる。今、座標D.at(i)をkとすると、
	     // 座標kまでで跳ねる回数はi回である。
	     //n+1までfor回して、L.at(i)がxをこしたらbreak;で通せそう
	     for(int i = 0 ; i < n+1 ; i++){
	       if(D.at(i)<=x){
	         ans ++;
	         }
	         else if(D.at(i)>x){
	           break;
	           }
	           }
	           cout << ans << endl;	      
	     
	   
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
using namespace std;
const int maxn = 100;
string s[maxn];
int main(){
    for (int i = 0; i < 3; i++){
         cin>>s[i];
    }
    cout<<s[0][0]<<s[1][1]<<s[2][2]<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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; }

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll N,ans;

int main(){
    cin>>N;
    ll x[N];
    rep(i,N){
        cin>>x[i];
    }
    rep(i,N-1){
        ans += ((x[N-1] - x[i]) * modinv(i+1,MOD)) % MOD;
    }
    repi(i,1,N)ans=(ans*i)%MOD;
    out(ans);
    
    
}

Measured memory_bytes: 1024
s = input()

ans = 0

for i in range(1 << (len(s) - 1)):
    last = 0
    sm = 0
    for j in range(len(s) - 1):
        if (i >> j) & 1:
            sm += int(s[last:j + 1])
            last = j + 1
    sm += int(s[last:])
    # print(i, sm)
    ans += sm
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1000000000
#define MOD 1000000007
#define M 15000007
#define N 100005
#define MAX 5032117	
#define LOG 100
#define KOK 333
using namespace std;

int n;
vector<ii> ans;
char s[N];

int main() {

	//freopen("input.txt","r",stdin);

	scanf("%s",s+1);

	n=strlen(s+1);

	for(int i=1;i<=n/2;i++) {

		if(s[i]!=s[n-i]) {

			printf("-1");

			return 0;

		}

	}

	if(s[n]=='1' || s[1]=='0') {

		printf("-1");

		return 0;

	}

	int cur=0;
	int sz=0;

	for(int i=1;i<n;i++) {

		if(s[i]=='1') {

			int add=i-cur-1;

			int last=i;

			for(int j=0;cur && j<=add;j++) {

				ans.pb({cur+j,i});

			}

			cur=i;

		}

	}

	ans.pb({n,n-1});

	for(ii i:ans) printf("%d %d\n",i.st,i.nd);

}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] w = new int[n];
		int s = 0;
		int[] sum = new int[n];

		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			s += w[i];
			sum[i] = s;
		}

		int min = 10000;

		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(s - 2 * sum[i]));
		}

		System.out.println(min);
	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

vi dp;
vvi G;

i64 calc_dist(i64 x){
  if(dp[x]>0) return dp[x];
  for(auto &p:G[x]) {
    chmax(dp[x], 1 + calc_dist(p));
  }
  return dp[x];
}

void Main()
{
  i64 N, M;
  cin >> N >> M;
  G.resize(N);

  i64 x, y;
  rep(i, M){
    cin >> x >> y;
    x--;
    y--;
    G[x].emplace_back(y);
  }

  dp.resize(N, 0);

  i64 ans = 0;
  rep(i, N) {
    chmax(ans, calc_dist(i));
  }

  cout << ans << "\n";

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 7680
#include <iostream>
#include <string>
#include <cmath>
 
using namespace std;
 
string s;
int dfs(int l, int r, int len){
    if(l < 0 || r >= s.size()) return len;
	int d = abs(s[l]-s[r]);
    if(d&&d<3) return dfs(l-1, r+1, len+2);
    return max(dfs(l-1, r, len), dfs(l, r+1, len));
}
 
int main(){ 
    cin >> s;
    int r, l = 0;
    while(s[l] != 'i') l++;
    cout << dfs(l-1, l+3, 3) << endl;
     
    return 0;
}

Measured memory_bytes: 1180
import math
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())

al1=t1*a1
al2=t2*a2
bl1=t1*b1
bl2=t2*b2

if al1>bl1:
    l1=al1
    l2=al2
    l3=bl1
    l4=bl2
else:
    l1=bl1
    l2=bl2
    l3=al1
    l4=al2

if al1+al2==bl1+bl2:
    print("infinity")
else:
    if (l1-l3)%(l1+l2-l3-l4)==0:
        ans=max(0,2*math.floor((l1-l3)/(l3+l4-l1-l2)))
        print(ans)
    else:
        ans=max(0,2*math.floor((l1-l3)/(l3+l4-l1-l2))+1)
        print(ans)
        
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int S,W;cin >> S >> W;
    if(S>W)cout << "safe" << endl;
    else cout << "unsafe" << endl;
    return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n,k;cin>>n>>k;
    VL a(n);
    REP(i,n){
        cin>>a[i];
    }
    SORT_ASC(a);

    LL result = 0;
    REP(i,k){
        result += a[i];
    }
    cout<<result<<endl;
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int a, b;
	cin >> a >> b;
	if (a % 3 && b % 3 && (a + b) % 3) {
		cout << "Impossible\n";
	}
	else {
		cout << "Possible\n";
	}
}

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


Measured memory_bytes: 256
max = 0
count = 0
ans = 0
5.times do |i|
    a = 0
    x =  gets.to_i
    amari = x % 10
    a = 10 - amari if amari != 0
    ans = ans + x + a
    if max <= a
        max = a
    end
end
puts ans - max


Measured memory_bytes: 1788
#include<stdio.h>

int w;
int h;
char map[20][21];

int solve(int x,int y){
  int count=1;

  if(x+1<w&&map[y][x+1]=='.'){
    map[y][x+1]='f';
    count+=solve(x+1,y);
  }
  if(x-1>-1&&map[y][x-1]=='.'){
    map[y][x-1]='f';
    count+=solve(x-1,y);
  }
  if(y+1<h&&map[y+1][x]=='.'){
    map[y+1][x]='f';
    count+=solve(x,y+1);
  }
  if(y-1>-1&&map[y-1][x]=='.'){
    map[y-1][x]='f';
    count+=solve(x,y-1);
  }
  return count;
}

int main(){
  int i,j,mx,my,found;
  do{
    found=0;
    scanf("%d %d",&w,&h);
    if(w==0&&h==0) break;
    for(i=0;i<h;i++){
      scanf("%s",map[i]);
      if(!found){
	for(j=0;j<w;j++){
	  if(map[i][j]=='@'){
	    mx=j;
	    my=i;
	    found=1;
	  }
	}
      }
    }
    printf("%d\n",solve(mx,my));
  }while(1);
  return 0;
}
      

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
char UP(char C)
{
    if(C>'Z')
        return C-32;
    return C;
}
int main()
{
    //ifstream cin("input.in");
    //ofstream cout("output.out");
    ios::sync_with_stdio(0);cin.tie(0);
    string S;
    cin>>S;
    cout<<UP(S[0]);
    cin>>S;
    cout<<UP(S[0]);
    cin>>S;
    cout<<UP(S[0]);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		ll n, m; scanf("%lld %lld", &n, &m); if (n == 0) break;
		vector<ll> a(n); for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
		ll res = 0;
		for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) if (a[i] + a[j] <= m) chmax(res, a[i] + a[j]);
		if (res == 0) puts("NONE");
		else printf("%lld\n", res);
	}
	return 0;

}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
unsigned long long sum=0;
char s[200010];
unsigned long long  a[27];
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    unsigned long long len=strlen(s);
    for(int i=0;i<len;i++)
    {
        a[s[i]-'a']++;
    }
    sum=len*(len-1)/2+1;
    for(int i=0;i<26;i++)
    {
        if(a[i]>=2)
        {
            sum-=(a[i]*(a[i]-1)/2);
        }
    }
    cout << sum <<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		String N = T.substring(0,S.length());	
		if(N.equals(S)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

int main(void){
	int i,b,c1,c2,q1,q2,sum,ansA,ansB;
	bool flg;

	while(cin>>q1 && q1){
		cin>>b>>c1>>c2>>q2;

		flg = false;
		for(ansA=q2;ansA>=1;ansA--){
			ansB = (b-c1*ansA);
			if(ansB >= 0) ansB /= c2;
			else ansB = -1;

			if(ansB >= 0 && ansA + ansB >= q1){
				flg = true;
				break;
			}
		}

		if(flg) cout<<ansA<<" "<<ansB<<endl;
		else cout<<"NA\n";
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) {
        ArrayList<ArrayList<ArrayList<Integer>>> rooms =
            new ArrayList<ArrayList<ArrayList<Integer>>>();
        for (int b = 0; b < 4; b++) {
            rooms.add(b, new ArrayList<ArrayList<Integer>>());
            for (int f = 0; f < 3; f++) {
                rooms.get(b).add(f, new ArrayList<Integer>());
                for (int r = 0; r < 10; r++) {
                    rooms.get(b).get(f).add(0);
                }
            }
        }
 
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
 
        for (int i = 0; i < n; i++) {
            int b = scanner.nextInt() - 1;
            int f = scanner.nextInt() - 1;
            int r = scanner.nextInt() - 1;
            int v = scanner.nextInt();
            rooms.get(b).get(f).set(r, rooms.get(b).get(f).get(r) + v);
        }

        for (int b = 0; b < 4; b++) {
            for (int f = 0; f < 3; f++) {
                for (int r = 0; r < 10; r++) {
                    System.out.print(" ");
                    System.out.print(rooms.get(b).get(f).get(r));
                }
                System.out.println("");
            }
            if (b != 3) {
                System.out.println("####################");
            }
        }
        scanner.close();
    }
}



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

typedef pair<int,int> P;

struct great{
	bool operator()(const P& x, const P& y) const{
		return x.first > y.first;
	}
};

int main(){
	int n,a,b,c,d,rank[100],same = 0;
	vector<P> vec;
	cin >> n;
	for(int i = 0;i < n;i++) vec.push_back(make_pair(0,i));
	for(int i = 0;i < (n * (n - 1)) / 2;i++){
		cin >> a >> b >> c >> d;
		if(c < d) vec[b - 1].first += 3;
		else if(c > d) vec[a - 1].first += 3;
		else {
			vec[a - 1].first++;
			vec[b - 1].first++;
		}
	}
	sort(vec.begin(),vec.end(),great());
	rank[vec[0].second] = 1;
	for(int i = 1;i < n;i++){
		if(vec[i].first == vec[i - 1].first){
			if(same == 0) same = i;
			rank[vec[i].second] = same;
		}
		else{
			rank[vec[i].second] = i + 1;
			same = 0;
		}
	}
	for(int i = 0;i < n;i++) cout << rank[i] << endl;
	return 0;
}

Measured memory_bytes: 1200
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int res[3][2];

int main() {
	int n;
	while(n=in()){
		int a,b,c;
		int i;
		memset(res,0,sizeof(res));
		for(i=0;i<n;i++){
			scanf("%d:%d %d",&a,&b,&c);
//cout<<(c-b+60)%60<<endl;
			if(11<=a&&a<=14){
				res[0][0]++;
				if((c-b+60)%60<=8)res[0][1]++;
			}else if(18<=a&&a<=20){
				res[1][0]++;
				if((c-b+60)%60<=8)res[1][1]++;
			}else if(a<=1||21<=a){
				res[2][0]++;
				if((c-b+60)%60<=8)res[2][1]++;
			}
		}
		cout<<"lunch ";
		if(res[0][0])cout<<res[0][1]*100/res[0][0];
		else cout<<"no guest";
		cout<<endl;
//cout<<res[0][0]<<" "<<res[0][1]<<endl;
		cout<<"dinner ";
		if(res[1][0])cout<<res[1][1]*100/res[1][0];
		else cout<<"no guest";
		cout<<endl;
//cout<<res[1][0]<<" "<<res[1][1]<<endl;
		cout<<"midnight ";
		if(res[2][0])cout<<res[2][1]*100/res[2][0];
		else cout<<"no guest";
		cout<<endl;
//cout<<res[2][0]<<" "<<res[2][1]<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  int count1=0;
  for(int i=0;i<N;i++){
    int b;
    cin >> b;;
    if(b%2==0){
      count1++;
    }
  }
  cout << pow(3,N)-pow(2,count1) << endl;
}



Measured memory_bytes: 256
//15:53-17:33
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,k;
vector<P1>vec;
vector<P>edge[10005];
bool good[10005];
bool used[10005],ok;
P forbid;
void dfs(int v){
	if(used[v]) return;
	if(good[v]) ok = 1; used[v] = 1;
	//cout << v << endl;
	for(int i=0;i<edge[v].size();i++){
		if(mp( min(v,edge[v][i].fi), max(v,edge[v][i].fi) ) == forbid){
			continue;
		}
		if(!used[edge[v][i].fi]) dfs(edge[v][i].fi);
	}
}
int main(){
	for(int q=1;;q++){
		scanf("%d%d%d",&n,&m,&k);
		if(n==0) return 0; memset(good,0,sizeof(good));
		vec.clear(); rep(i,10005) edge[i].clear();
		for(int i=1;i<n;i++){
			int a,b,c; scanf("%d%d%d",&a,&b,&c);
			vec.pb(mp(c,mp(a,b)));
			edge[a].pb(mp(b,c));
			edge[b].pb(mp(a,c));
		}
		for(int i=0;i<m;i++){
			int x; cin >> x; good[x] = 1;
		}
		rep(i,1005) SORT(edge[i]);
		sort(vec.begin(),vec.end());
		ll ret = 0;int c = 0;
		for(int i=0;i<vec.size()&&c<k;i++){
			memset(used,0,sizeof(used));
			int cs = vec[i].fi;
			int L = vec[i].sc.fi,R = vec[i].sc.sc;
			forbid = mp(min(L,R),max(L,R));
			ok = 0;
			dfs(L);
			if(!ok) continue;
			ok = 0;
			dfs(R);
			if(!ok) continue;
			edge[L].erase(lower_bound(edge[L].begin(),edge[L].end(),mp(R,cs)));
			edge[R].erase(lower_bound(edge[R].begin(),edge[R].end(),mp(L,cs)));
			c++; ret += cs; //cout << ret << endl;
		}
		cout << "Case " << q << ": " << ret << endl;
	}
}

Measured memory_bytes: 4288
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
p = list(lf())
dp = [[0]*(n+1) for _ in range(n+1)]

dp[0][0] = 1
for o in range(n):
    for u in range(n):
        if o+u >= n:
            continue
        
        dp[o][u+1] += (1-p[o+u]) * dp[o][u]
        dp[o+1][u] += p[o+u] * dp[o][u]
        
ans = 0
for o in range(n+1):
    u = n-o
    if o > u:
        ans += dp[o][u]
        
print(ans)

Measured memory_bytes: 253192
#include<iostream>
#include<cstdio>
using namespace std;
int N,X[3];
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d",&X[i]);
	for(int i=1;i<=1e8;i++){
		bool f=true;
		for(int j=0;j<N;j++){
			if(X[j]%i!=0)f=false;
		}
		if(f)printf("%d\n",i);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
	int n;
	cin >> n;
	int x;
	cin >> x;
	int m[n];
	int i;
	int s = 0;
	for( i = 0; i < n; i++){
		cin >> m[i];
		s += m[i];
	}
	int min = m[0];

  for (i = 0; i < n; i++)
    {
      if (m[i] < min)
        {
          min = m[i];
        }
    }
	int d = x - s;
	if(s == x){
		cout << n<<endl;
	}
	else {
		cout << n + (d / min)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n,k; cin >> n >> k; ll sum = 0;
  vl num(n);
  
  rep(i,n) cin >> num[i];
  
  sort(all(num));
  
  rep(i,k) sum += num[n-1-i];
  
  cout << sum << endl;
  
  
}

Measured memory_bytes: 3640
def solve(h, w, b)
    x, y = 0, 0
    loop.with_index do |_, i|
        if i == h * w
            puts "LOOP"
            break
        end
        case b[y][x]
            when '>' then
                x += 1
            when '<' then
                x -= 1
            when 'v' then
                y += 1
            when '^' then
                y -= 1
            when '.' then
                puts "#{x} #{y}"
                return
        end
    end
end

loop do
    h, w = gets.chomp.split(' ').map(&:to_i)
    break if h == 0 && w == 0
    b = h.times.collect do
        gets.chomp.split('')
    end
    solve(h, w, b)
end

Measured memory_bytes: 9060
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <sstream>


using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int a, c, ans = 0;
	char b;
	while (1)
	{
		cin >> a >> b >> c;
		if (b == '?') break;
		switch (b)
		{
		case('+'): ans = a + c; break;
		case('-'): ans = a - c; break;
		case('*'): ans = a * c; break;
		case('/'): ans = a / c; break;
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

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

  int cnt = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        int a = 500 * i + 100 * j + 50 * k;
        if (a == X) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#define llint long long
#define mod 998244353
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[305];
llint dp[305][45005][2][2];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

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

  cin >> n;
  for(int i = 1; i <= n; i++) cin >> a[i];

	llint s = 0;
	for(int i = 1; i <= n; i++) s += a[i];
	llint m = s/2;

	dp[0][0][0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= m; j++){
			for(int k = 0; k < 2; k++){
				for(int l = 0; l < 2; l++){
					dp[i+1][j][k][l] += dp[i][j][k][l], dp[i+1][j][k][l] %= mod;
					if(j+a[i+1] <= m){
						dp[i+1][j+a[i+1]][1][l] += dp[i][j][k][l], dp[i+1][j+a[i+1]][1][l] %= mod;
						if(k+l>0) dp[i+1][j+a[i+1]][k][1] += dp[i][j][k][l], dp[i+1][j+a[i+1]][k][1] %= mod;
					}
				}
			}
		}
	}
	//for(int j = 0; j <= m; j++) cout << dp[n][j][1][1] << " "; cout << endl;

	llint sum = 0;
	for(int j = 1; j <= m; j++) sum += dp[n][j][1][1], sum %= mod;
	sum *= 6, sum %= mod;
	//cout << sum << endl;

	sum += (modpow(2, n-1)+mod-1)%mod*6%mod, sum %= mod;
	sum += 3, sum %= mod;
	//cout << sum << endl;

	llint ans = modpow(3, n);
	ans += mod - sum, ans %= mod;
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 422784
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,W;
  cin >> N >> W;
  vector<int> w(N),v(N);
  for(int i=0;i<N;i++)  cin >> w.at(i) >> v.at(i);

  vector<vector<int>> dp(N+1,vector<int>(N*1000+1,1e9+1));
  dp.at(0).at(0)=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N*1000+1;j++){
      if(j-v.at(i)>=0)  dp.at(i+1).at(j)=min(dp.at(i).at(j),dp.at(i).at(j-v.at(i))+w.at(i));
      else dp.at(i+1).at(j)=dp.at(i).at(j);
    }
  }
  for(int i=N*1000;i>=0;i--){
    if(dp.at(N).at(i)<=W){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 40192
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	long a = sc.nextLong();
      	long b = sc.nextLong();
      	long x = sc.nextLong();
      	if(a == 0) a = 1 - x;
      	long ans = b / x - (a - 1) / x;
		System.out.println(ans);
	}
}


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

if len(A) == 2:
    print(A[0], A[1])
else:
    res0 = max(A)
    temp = max(A) / 2

    hoge = 9999999999
    for a in A:
        if abs(a - temp) < hoge:
            hoge = abs(a - temp)
            res1 = a

    print(res0, res1)

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

using namespace std;
int main(){
    int n, max, total = 0;
    cin >> n;
    int a [n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        total += a[i];
    }
    sort(a, a + n);
    total -= a[n - 1] / 2;
    cout << total << endl;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
*a, = map(int, input().split())
c = Counter(a)
used = set(c.keys())
size = len(used)

if 0 in used and size==1:
    print("Yes")
elif 0 in used and size==2 and c[0]==N//3:
    print("Yes")
elif size==3:
    s, t, u = used.pop(), used.pop(), used.pop()
    if s^t^u==0 and c[s]==c[t]==c[u]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cerr << #x << " = " << x << endl;

template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}

template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}

template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}

template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}

void solve(); signed main() {
#ifdef LOCAL
    freopen("C:\\Users\\artma\\CLionProjects\\problems\\input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();
    return 0;
}

const int MOD = 1e9 + 7, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 37;

void solve() {
    string s;
    cin >> s;
    int ans = 0;
    int i = 0;
    while (i < $(s)) {
        char tmp = s[i];
        int cnt = 0;
        while (i < $(s) && s[i] == tmp) {
            i++;
            cnt++;
        }
        if (tmp == 'R') {
            ans = max(ans, cnt);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    if((A<=9&&A>=1)&&(B>=1&&B<=9)&&(C>=1&&C<=9)){
    if((A==C&&B!=A)||(A==B&&C!=A)||(B==C&&A!=C)) printf("Yes");
    else printf("No");
    return 0;
    }
    else return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main(void){
  float A,B,C,D,e;
  scanf("%f %f %f %f",&A,&B,&C,&D);
  e=A+B-C-D;
  if(e>0){
    printf("Left");
  }else if(e==0){printf("Balanced");
                }else{printf("Right");
                             }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main()
{
    int x,a,b;
    while(scanf("%d%d%d",&x,&a,&b)==3)
    {
       if(fabs(x-a)<fabs(x-b))printf("A\n");
       else printf("B\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

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

    int ans = 0;
    for(int i = 0; i < n; i++){
        int l, r, sa;
        scanf("%d%d", &l, &r);
        sa = r - l + 1;
        ans = ans + sa;
    }

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

    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int t[3];
    for(int i=0;i<3;i++)
        cin >> t[i];
    
    // 昇順ソート
    sort(t, t + 3);

    cout << t[0] + t[1] << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int dp[2010][2010] = {0};
int sm[2010][2010] = {0};
signed main(){
    
    int n,m;
    cin >> n >> m;
    vector<int> s(n);
    vector<int> t(m);

    rep(i,n)cin >> s[i];
    rep(i,m)cin >> t[i];

    //rep(i,2005)dp[i][0] = dp[0][i] = 1;
    
    // for(int i = 1;i <= n;i++){
    //     for(int j = 1;j <= m;j++){
    //         if(s[i-1] == t[j-1]){
    //             dp[i][j] = (dp[i][j-1] + dp[i-1][j])%MOD;
    //         }else{
    //             dp[i][j] = (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1])%MOD;
    //         }
    //     }
    // }
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= m;j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = (dp[i-1][j] + dp[i][j-1] + 1)%MOD;
            }else{
                dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]+MOD)%MOD;
            }
        }
    }
    cout << (dp[n][m]+1)%MOD << endl;

    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc130.contest.atcoder.jp/tasks/abc130_b

Measured memory_bytes: 32512
W,H = map(int,input().split())

t = H+1
y = W+1

ans = 0

lis = []

for i in range(W):
    p = int(input())
    lis.append([p,"y",i])

for i in range(H):
    q = int(input())
    lis.append([q,"t",i])

lis.sort()

for i in lis:

    ncost = i[0]
    ndir = i[1]
    #print (i,ans)

    if ndir == "t":
        t -= 1
        ans += ncost * max(0 , y)

    else:
        y -= 1
        ans += ncost * max(0 , t)

print (ans)


Measured memory_bytes: 89964
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
  	cin>>a>>b>>c>>d;
  	int X,Y,Z;
  	if(a-c<0){
    	X = -a+c;
    }
  	else {
    	X=a-c;
    }
	if(a-b<0){
    	Y=-a+b;
    }
  	else{
    	Y=a-b;
    }
  	if(b-c<0){
    	Z=-b+c;
    }
	else{
    	Z=b-c;
    }
	if(X <=d || Y<=d&&Z<=d){
    	cout<<"Yes"<<endl;
    }
  	else{
    	cout<<"No"<<endl;
    }
  
    
  
}

Measured memory_bytes: 256
def color(rating):
    d = {'gray': (1, 399), \
         'brown': (400, 799), \
         'green': (800, 1199), \
         'cyan': (1200, 1599), \
         'blue': (1600, 1999), \
         'yellow': (2000, 2399), \
         'orange': (2400, 2799), \
         'red': (2800, 3199), \
         'any': (3200, 4800)}
    for k, v in d.items():
        if rating >= v[0] and rating <= v[1]:
            return k

def count(colors):
    different_colors = set(colors)
    num_colors = len(different_colors) - ('any' in different_colors)
    anys = colors.count('any')
    if num_colors == 0 and anys > 0:
        minimum = 1
    else:
        minimum = num_colors
    maximum = num_colors + anys
    return (minimum, maximum)


if __name__ == '__main__':
    _ = input()
    ratings = map(int, input().split())
    colors = list(map(lambda x: color(x), ratings))
    minimum, maximum = count(colors)
    print(minimum, maximum)

Measured memory_bytes: 3064
import * as fs from 'fs';

const WALL = '#';
const ROAD = '.';

class Mazer {
  public warpRange = 2;
  public warpCount = 0;
  public expandableList: [number, number][] = [];
  constructor(public h: number, public w: number, public maze: (string | number)[][], public ch: number, public cw: number, public dh: number, public dw: number) {
    this.expandableList.push([ch, cw]);
  }

  solve(): number | null {
    while (this.expandableList.length > 0) {
      const expandableList = this.expandableList;
      this.expandableList = [];
      while (expandableList.length > 0) {
        const expandable = expandableList.pop();
        this.expand(expandable[0], expandable[1]);
        if (this.isSolved()) {
          const status = this.getMas(this.dh, this.dw);
          return status as number;
        }
      }
      this.warpCount++;

    }

    return null;
  }

  expand(i: number, j: number) {
    const openList: [number, number][] = [[i, j]];
    while (openList.length > 0) {
      const pos = openList.pop();
      if (!this.isRange(pos[0], pos[1])) {
        continue;
      }
      const masu = this.getMas(pos[0], pos[1]);
      if (masu !== ROAD) {
        continue;
      }
      this.setMas(pos[0], pos[1], this.warpCount);
      this.expandWarpable(pos[0], pos[1]);
      for (let [x, y] of [[1, 0], [0, 1], [-1, 0], [0, -1]]) {
        openList.push([x + pos[0], y + pos[1]]);
      }
    }
  }

  expandWarpable(i: number, j: number) {
    for (let x = -this.warpRange; x <= this.warpRange; x++) {
      for (let y = -this.warpRange; y <= this.warpRange; y++) {
        if (!this.isRange(i + x, j + y)) {
          continue;
        }
        const status = this.getMas(i + x, j + y);
        if (status === WALL) {
          continue;
        }
        if (status === ROAD || status > this.warpCount + 1) {
          // this.setMas(i + x, j + y, this.warpCount + 1);
          this.expandableList.push([i + x, j + y]);
        }
      }
    }
  }

  isSolved(): boolean {
    return this.getMas(this.dh, this.dw) !== ROAD;
  }

  isRange(i: number, j: number): boolean {
    return (1 <= i && i <= this.h && 1 <= j && j <= this.w);
  }

  getMas(i: number, j: number): string | number {
    if (!this.isRange(i, j)) {
      throw new Error('range error');
    }
    return this.maze[i - 1][j - 1];
  }

  setMas(i: number, j: number, status: string | number): void {
    if (!this.isRange(i, j)) {
      throw new Error('range error');
    }
    this.maze[i - 1][j - 1] = status;
  }
}


function main(input) {
  input = input.split("\n");
  const [h, w] = input[0].split(' ').map(i => parseInt(i));
  const [ch, cw] = input[1].split(' ').map(i => parseInt(i));
  const [dh, dw] = input[2].split(' ').map(i => parseInt(i));
  const maze: number[][] = [];
  for (let i = 0; i < h; i++) {
    maze.push(input[i + 3].split('').map(i => i));
  }
  const mazer = new Mazer(h, w, maze, ch, cw, dh, dw);
  const result = mazer.solve();
  console.log('%d', result !== null ? result : -1);
  return 0;
}

main(fs.readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 112920
n = int(input())
ret = ''
while n != 0:
  d, r = n // (-2), n % (-2)
  if r == -1: # (d+1) * (-2) + 1 = n
    r = 1
    d += 1
  ret += str(r)
  n = d
if ret == '':
  ret = '0'
else:
  ret = ret[::-1]
print(ret)
  

Measured memory_bytes: 2940
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
(N,M) = (int(i) for i in input().split(" "))
print(N-M+1)

Measured memory_bytes: 4208