akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll mod=1000000007;

ll kai(ll a){
  if(a==1) return 1;
  else{
    return a*kai(a-1)%mod;
  }
}
ll kai2(ll a){
  int c=1;
  for(int i=1;i<=a;i++){
    c*=i;
    c%=mod;
  }
  return c;
}

int main(){
  int n,m; cin>>n>>m;
  if(abs(n-m)>1)
  cout<<0<<endl;
  else{
    ll ans=1;
    if(n<m) swap(n,m);
    if(n==m) ans*=2;
    for(int i=1;i<=n;i++){
      ans*=i;
      ans%=mod;
    }
    for(int i=1;i<=m;i++){
      ans*=i;
      ans%=mod;
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define ll long long
#define fr(i,a,b) for (int i=a ; i<b ; i++)
#define fre(i,a,b) for (int i=a ; i<=b ; i++)
#define mem(a, b) memset(a, (b), sizeof(a))
#define mp make_pair
#define pb push_back
#define inf (int)1e9
#define pii 3.1415926535897932384626433832795
#define mod 1000000007
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pi> vii;
typedef map<int,int> mi;
typedef set<int> si;

int a[100005];
long dp[100005];


int main() {
    FAST_IO;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    int k;
    cin>>n; cin>>k;
    fre(i,1,n)
    	cin>>a[i];
    mem(dp,0);
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for(int i=3;i<=n;i++){
    	dp[i] = inf;
    	if(k<i){
    		for(int j=i-1; j>=i-k;j--){
    			dp[i] = min(dp[i],(abs(a[i] - a[j]) + dp[j]));
    		}
    	}
    	else{
    		for(int j= i-1; j>=1;j--){
    			dp[i] = min(dp[i],(abs(a[i] - a[j]) + dp[j]));
    		}
    	}
    }
    cout<<dp[n]<<endl;
}

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

typedef long long ll;

int main() {
  ll N; cin >> N;
  ll h, n, w;

  for(n=1; n<=3500; n++){
    for(w=1; w<=3500; w++){
      if(((4*n*w) - (N*w) - (N*n)) <= 0) continue;
      ll a,b;
      a = N*n*w; b = (4*n*w) - (N*w) - (N*n);
      if(b > 0 && a%b==0){
        cout << a/b <<" "<< n <<" "<< w << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]){
  int N;
  string S;
  std::cin >> N;
  std::cin >> S;
  int ans = MODs;
  std::vector<int> kuro(S.size()+1);
  kuro[0] = 0;
  range(i, S.size()){
    if(S[i] == '#') kuro[i+1] = kuro[i] + 1;
    else kuro[i+1] = kuro[i];
  }
  range(i, S.size()+1){
    int reg = kuro[i] + S.size() - i - (kuro[S.size()] - kuro[i]);
    ans = min(ans, reg);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
// 1528
// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
    int a,b;cin>>a>>b;
    int ans = INT_MAX;

    for(int i=10*b;i<10*b+10;++i)
    {
    	int x = (int) (i*0.08);
    	if(x==a)
    	{
    		ans = min(ans,i);
    	}
    }
    if(ans==INT_MAX)cout<<"-1";
    else 	cout<<ans<<"\n";
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int A,B;
    cin >> A >> B;
    
    if( (B-1)%(A-1)==0 ) cout << (B-1)/(A-1) << endl;
    else cout << (B-1)/(A-1) + 1<< endl;
}


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

int main (){
	string s;
    int ans =0;
	cin >> s;
    for(int i = 0; i< s.size(); i++ ){
        if(i%2!=0){
            if(s[i]=='L' ||s[i]=='U' ||s[i]=='D' ){
                ans +=1;
            }
        }
        if(i%2==0){
            if(s[i]=='R' ||s[i]=='U' ||s[i]=='D' ){
                ans +=1;
            }
        }
    }
    
    if(ans == s.size()){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl; 
    }
    return 0;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner i =new Scanner(System.in);
		int r = i.nextInt();
		
		int h =Math.round(r/(60*60));
		int m =Math.round(r%(60*60)/60);
		int s =Math.round(r%(60*60)%60);
		System.out.println(h+":"+m+":"+s);
	}
}

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

int main()
{
    int n, result = 0;

    cin >> n;

    vector<int> l(n);

    for(int i = 0; i < l.size();i++)
    {
        cin >> l.at(i) ;
    }
    sort(l.begin(),l.end());

    for(int i = 0; i < n; i++)
    {
        for (int j = 0 ; j < i ;  j++)
        {
            for(int t = 0; t < j;t++)
            {
                if((l.at(t) != l.at(j)) and (l.at(t) != l.at(i))and (l.at(j) != l.at(i)) and (l.at(i) < l.at(t) + l.at(j)))
                {
                    result++;   
                }
            }
        }

    }

    cout << result << endl;
    return 0;
}

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans = n * a;
    if (b < ans)
    {
        ans = b;
    }
    cout << ans << endl;
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll k,a,b;
  cin >> k >> a >> b;

  ll ans = 1;
  if(b-a<2)
    ans += k;
  else{
    if(k<a-1)
      ans += k;
    else{
      ans += a-1;
      k -= a-1;
      ans += k/2*(b-a);
      ans += k%2;
    }
  }

  cout << ans << endl;

}


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

vector<int> topological_sort (const vector<vector<int>> &g) {
	const int n = g.size();
	vector<int> sorted, indeg(n, 0);
	vector<bool> processed(n, false);

	for (int v = 0; v < n; v++) {
		for (int u : g[v]) indeg[u]++;
	}

	for (int s = 0; s < n; s++) {
		if (indeg[s] > 0 or processed[s]) continue;
		queue<int> que;
		que.push(s);
		processed[s] = true;
		while (not que.empty()) {
			int v = que.front();
			que.pop();
			sorted.push_back(v);
			for (const int &u : g[v]) {
				if (--indeg[u] == 0 and not processed[u]) {
					que.push(u);
					processed[u] = true;
				}
			}
		}
	}

	return sorted;

}


int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
	}
	
	for (int v : topological_sort(g)) {
		cout << v << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 3684
#include <stdio.h>
#include <string.h>
int main(){
  int i,j,k;
  char s[1000000]={0};
  while(scanf("%d %d",&i,&j) != EOF){
    k=0;
    k=i+j;
    sprintf(s,"%d",k);
    i=strlen(s);
    printf("%d\n",i);
  }
    return (0);
}

Measured memory_bytes: 1596
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
	int m,n;
	cin>>n>>m;
	if(m>n){
		for(int i=0;i<m;i++)
			cout<<n;
	}
	else
		for(int i=0;i<n;i++)
			cout<<m;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int n;
    cin>>n;
    ll ans=0;
    vector<ll>arr(n);
    for(int i=0; i<n; i++)
     cin>>arr[i];
    ll last=arr[0];
    for(int i=1; i<n; i++){
    	if(arr[i]>last)
    	  last=arr[i];
    	else{
    		ans+=(last-arr[i]);
		}
	}
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<ll, ll>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define int ll


signed main(){
    ll k;
    cin >> k;
    ll x, y;
    cin >> x >> y;
    bool rx = false;
    bool ry = false;
    bool rxy = false;
    if (x<0) {
        x = -x;
        rx = true;
    }
    if (y<0) {
        y = -y;
        ry = true;
    }
    if (x<y) {
        swap(x, y);
        rxy = true;
    }
    if (k%2==0 && (x+y)%2==1) {
        cout << "-1" << endl;
        return 0;
    } 

    vector<P> ans;
    int n;

    if (x+y<k) {
        if ((x+y)%2==0) {
            n = 2;
            int d1 = (k*n-x-y)/2;
            ans.emplace_back(k-d1, -d1);
            ans.emplace_back(x, y);
        }
        else {
            n = 3;
            int d1 = k-x;
            int d2 = x+(k+x-y)/2;
            ans.emplace_back(k-d1, -d1);
            ans.emplace_back(d2, 2*k-d1-d2-d1);
            ans.emplace_back(x, y);
        }
    }
    else {
        int c = (k-(x+y)%k) % k;
        int d1, d2;
        if (c%2==0) {
            n = (x+y-1)/k+1;
        }
        else {
            n = (x+y-1)/k+2;
        }
        d1 = (k*n-x-y)/2;
        d2 = d1 + x;
        rep(i, n) {
            ll sum = (ll)k * (i+1);
            int ix, iy;
            if (sum<=d1) {
                ix = 0LL;
                iy = -sum;
            }
            else if (sum<=d2) {
                ix = sum - d1;
                iy = -d1;
            }
            else {
                ix = x;
                iy = sum - d2 - d1;
            }
            ans.emplace_back(ix, iy);
        }
    }
    cout << n << endl;
    rep(i, n) {
        if (rxy) swap(ans[i].first, ans[i].second);
        if (ry) ans[i].second *= -1;
        if (rx) ans[i].first *= -1;        
        cout << ans[i].first << " " << ans[i].second << endl;
    }

    
    return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n),b(n);
  for (int i=0;i<n;++i) cin >> a[i] >> b[i];
  
  vector<pair<int, int>> ab(n);
  for (int i=0;i<n;++i){
    ab[i]=make_pair(a[i],b[i]);
  }
  sort(ab.begin(),ab.end());
  
  long long ans=0;
  for (int i=0;i<n;++i){
    //このお店で買う数を決める
    int buy=min(m,ab[i].second);
    
    //買った金額を加算する
    ans+=(long long)buy*ab[i].first;

    //残り本数を減らす
    m-=buy;
  }
  cout << ans << endl;
}

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

int main(){
  int N,Q,M,a;

  while(cin>>N>>Q){
    if(N==0&&Q==0)break;
    int max=0,b[51][101]={},count=0,c,d=100;

    for(int i=0;i<N;i++){
      cin>>M;
      if(max<M)max=M;
      for(int j=0;j<M;j++){
	cin>>a;
	b[i][j]=a;
      }
    }

    for(int i=0;i<N;i++)
      for(int j=0;b[i][j]!=0;j++){
	int count1=0;
	for(int l=0;l<N;l++)
	  for(int k=0;b[l][k]!=0;k++)
	    if(b[i][j]==b[l][k]){
	      count1++;
	      if(Q<=count1){
		if(count<count1){
		  count=count1;
		  d=b[i][j];
		}
		else if(count==count1){
		  count=count1;
		  c=b[i][j];
		  if(d>c)d=c;
		}
	      }
	    }
      }	  
    if(d==100)cout<<0<<endl;
    else cout<<d<<endl;     
  }
  return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int h[100010];
int dp[100010];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%d", h + i);
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for(int i = 3; i <= n; i++)
    {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),
                    dp[i-2] + abs(h[i] - h[i - 2]));
    }
    printf("%d\n", dp[n]);
    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	map<string, map<int,int, greater<int>>> mapping;
	
	for(int i=1; i <= n; i++) {
		string name;
		int score;
		cin >> name >> score;
		
		mapping[name][score] = i;
	}
	
	for(auto& town : mapping) {
		for(auto& score : town.second) {
			cout << score.second << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char s[100000];
    int n, m, i;
    
    scanf("%d",&n);
    scanf("%s",s);
    
    m=strlen(s);
    for(i=0;i<m;i++) s[i]='A'+(s[i]-'A'+n)%26;
    
    printf("%s",s);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long int i = (a); i < (b); i++)

using namespace std;
using ll = long long int;
using ld = long double;

auto p = [](auto s){
    cout << s << endl;
};

int main() {
    int N;
    cin >> N;
    cout << setprecision(10) << N * 2.0 * 3.14159265 << endl;
    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n, k) for(long i = k; i < n; i++)
using namespace std;

long lcm(long x, long y){
  long tmp, r, a;
  a = x * y;
  if(x < y){
    tmp = x;
    x = y;
    y = tmp;
  }
  r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return a / y;
}

int main(){
  long a, b, c, d, esum, sum, csum, dsum, ans = 0;
  cin >> a >> b >> c >> d;
  
  sum = b - a + 1;
  csum = b/c - (a - 1)/c;
  dsum = b/d - (a - 1)/d;
  esum = b/lcm(c, d) - (a-1)/lcm(c, d);
  
  ans = sum - csum - dsum + esum;
  cout << ans << endl;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
while (true) {
   var n = arr.shift() - 0;
   if (n == 0) break;
   var nww = [];
   for (var i = 0; i < n; i++) nww[i] = arr.shift().split(" ");
   nww = nww.map(v => [v[0], v[1] - 0, v[2] - 0]);
   nww.sort((a,b)=>{
      return b[1]-a[1];
   });
   var max = 0;
   var ans = [];
   var bomb = function (arrA, arrB, sum, g) {
      if (arrB.length == 0) {
         if (max < g / sum) {
            ans = arrA;
            max = g / sum;
         }
         return;
      }
      for(var i=0;i<arrB.length;i++){
         var v=arrB[i];
         if (sum <= nww[v][2]) {
            var a = arrA.concat(v);
            var b = arrB.filter(n => v != n);
            bomb(a, b, sum + nww[v][1], g + nww[v][1] * (arrA.length + 1));
         }
      }
   };
   var bombArr = [];
   for (var i = 0; i < n; i++) bombArr.push(i);
   bomb([], bombArr, 0, 0);
   console.log(ans.map(v => nww[v][0]).reverse().join("\n"));
}


Measured memory_bytes: 19356
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let rec atk num H = if H=1L then num else ((atk (num*2L) (H/2L))+num)
    R int64
    |>atk 1L
    |>stdout.WriteLine
    0

Measured memory_bytes: 13268
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int x,y,a,r,g,b;
    cin>>r>>g>>b;
    x=r*100+g*10+b;
    if(x%4==0){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
s = input().strip()
x,y = map(int,input().split())
C = {}
cur = 0
cnt = 0
for i in range(len(s)):
    if s[i]=="F":
        cnt += 1
    else:
        C[cur] = cnt
        cur += 1
        cnt = 0
C[cur] = cnt
AX = []
AY = []
for a in C:
    if a>0 and a%2==0 and C[a]>0:
        AX.append(C[a])
    elif a%2==1 and C[a]>0:
        AY.append(C[a])
cntx = sum(AX)
dpx = [[0 for _ in range(2*cntx+1)] for _ in range(len(AX)+1)]
dpx[0][cntx] = 1
if cntx>0:
    dpx[1][cntx-AX[0]] = 1
    dpx[1][cntx+AX[0]] = 1
    for i in range(2,len(AX)+1):
        for j in range(-cntx,cntx+1):
            if -cntx<=j-AX[i-1]:
                dpx[i][j+cntx] = dpx[i-1][j-AX[i-1]+cntx]
                if j+AX[i-1]<=cntx:
                    dpx[i][j+cntx] = max(dpx[i][j+cntx],dpx[i-1][j+AX[i-1]+cntx])
            elif j+AX[i-1]<=cntx:
                dpx[i][j+cntx] = dpx[i-1][j+AX[i-1]+cntx]
cnty = sum(AY)
dpy = [[0 for _ in range(2*cnty+1)] for _ in range(len(AY)+1)]
dpy[0][cnty] = 1
if cnty>0:
    dpy[1][cnty-AY[0]] = 1
    dpy[1][cnty+AY[0]] = 1
    for i in range(2,len(AY)+1):
        for j in range(-cnty,cnty+1):
            if -cnty<=j-AY[i-1]:
                dpy[i][j+cnty] = dpy[i-1][j-AY[i-1]+cnty]
                if j+AY[i-1]<=cnty:
                    dpy[i][j+cnty] = max(dpy[i][j+cnty],dpy[i-1][j+AY[i-1]+cnty])
            elif j+AY[i-1]<=cnty:
                dpy[i][j+cnty] = dpy[i-1][j+AY[i-1]+cnty]
if C[0]-cntx<=x<=C[0]+cntx and dpx[len(AX)][x-C[0]+cntx]==1 and -cnty<=y<=cnty and dpy[len(AY)][y+cnty]==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 173704
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define sll(n) scanf("%lld",&n)
#define sll2(x,y) scanf("%lld%lld",&x,&y)
#define sll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define REP(i,x,y) for(ll i = x;i <= y;++i)
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z))
        ;
    return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
void localTest() {
    #ifndef ONLINE_JUDGE
        freopen("inp", "r", stdin);
        freopen("out", "w", stdout);
    #endif      
}
int main() {

    //localTest();
    ll k, a, b;
 	sll3(k, a, b);
 	ll res = b / k - (a - 1) / k ;
 	if(res) printf("OK\n");
 	else printf("NG\n");

    return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,vl>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll a;
    cin >> a;
    ll b;
    cin >> b;
    ll x;
    cin >> x;
    ll B=b/x;
    ll A=(a-1)/x;
    if(a>0)
    print(B-A);
    else if(a==0&&b>0)
    print(B+1);
    else print(1);
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}

void Main()
{
	ll N,M;
	ll res=0;
	cin>>N>>M;
	VI H(N),A(M),B(M);
	REP(i, N) cin >> H[i];
	VVI bridge(N);
	vector<map<ll,ll>> link(N);
	REP(i,M) {
		cin >> A[i] >> B[i];
		A[i]--,B[i]--;
		bridge[A[i]].emplace_back(B[i]);
		bridge[B[i]].emplace_back(A[i]);
	}
	REP(i,N){
		ll val=H[i];
		//bridgeを全探査
		if(SIZE(bridge[i])==0){
			res++;
			continue;
		}

		bool conti=false;
		REP(j,SIZE(bridge[i])){
			ll h=H[bridge[i][j]];
			if(h>=val) {
				conti=true;
			}
		}
		if(!conti)	res++;
		//if(比べ)res++;
		//bridgeが一つも無ければres++;
	}


	cout << res << "\n";
	return;
}

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


Measured memory_bytes: 16112
from math import sqrt
n = int(input())
p = []

for i in range(n):
    x,y = map(int, input().split())
    p.append((x,y))
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        x1,y1=p[i]
        x2,y2=p[j]
        d=sqrt((x1-x2)**2+(y1-y2)**2)
        ans+=d
ans/=n/2
print(ans)


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

costs = [0]*n
values = []

for i in range(n):
    v = list(map(int, input().split()))
    costs[i] = v[0]
    values.append(v[1:])

candidates = []
for i in range(pow(2, n)):

    learning = [0]*m
    currentCost = 0
    for bit in range(n):
        select = i >> bit & 1
        if select == 1:
            currentCost += costs[bit]
            for j, v in enumerate(values[bit]):
                learning[j] += v

    if all([l >= x for l in learning]):
        candidates.append(currentCost)

print((-1 if len(candidates) == 0 else min(candidates)))

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> a(n);
    map<ll, ll> mp;
    REP(i, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    if(mp.size() == 1) {
        if(mp.find(0) != mp.end()) {
            cout << "Yes" << en;
            return;
        }
    } else if(n % 3 == 0) {
        if(mp.size() == 2 and mp.find(0) != mp.end()) {
            if(mp[0] == n / 3) {
                cout << "Yes" << en;
                return;
            }
        } else if(mp.size() == 3) {
            Array b;
            for(auto i : mp) {
                if(i.second != (n / 3))
                    break;
                b.push_back(i.first);
            }
            if(b.size() == 3) {
                if((b[0] ^ b[1]) == b[2]) {
                    cout << "Yes" << en;
                    return;
                }
            }
        }
    }

    cout << "No" << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 8720
fun main() {
    val (n, m, q) = readLine()!!.split(' ').map { it.toInt() }
    val qs = (0 until q).map { readLine()!!.split(' ').map { it.toInt() } }

    fun dfs(xs: List<Int>): Int {
        if (xs.size == n + 1) {
            return qs.map { (a, b, c, d) -> if (xs[b] - xs[a] == c) d else 0 }.sum()
        }
        return (xs.last()..m).map { dfs(xs + it) }.max()!!
    }

    println(dfs(listOf(1)))
}


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

int cnt[505][505];

signed main(){
    
  int n,m,q;
  cin >> n >> m >> q;

  for(int i = 0;i<m;i++){
    int l,r;
    cin >> l >> r;
    cnt[l][r]++;
  }

  for(int i = 1;i<=n;i++){
    for(int j = i+1;j<=n;j++)
      cnt[i][j]+=cnt[i][j-1];
  }

  for(int i = 1;i<=n;i++){
    for(int j = i-1; j>=1;j--)
      cnt[j][i]+=cnt[j+1][i];
  }

  while(q--){
    int l,r;
    cin >> l >> r;

    cout << cnt[l][r] << endl;
  }
  return 0;
}
    
  


Measured memory_bytes: 2944
import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

accum_a = [0] * (n + 1)
for i in range(1, n + 1):
    accum_a[i] = accum_a[i - 1] + a[i - 1]

accum_b = [0] * (m + 1)
for i in range(1, m + 1):
    accum_b[i] = accum_b[i - 1] + b[i - 1]

max_cnt = 0
for a_cnt in range(n + 1):
    if accum_a[a_cnt] > k:
        break

    b_cnt = bisect.bisect_right(accum_b, k - accum_a[a_cnt]) - 1

    sum_cnt = a_cnt + b_cnt
    if sum_cnt > max_cnt:
        max_cnt = sum_cnt

print(max_cnt)


Measured memory_bytes: 47388
n = gets.rstrip.to_i
hs = gets.rstrip.split.map(&:to_i)

dp = Array.new(n, 0)
1.upto(n-1) do | i |
  if i==1
    dp[i] = (hs[i] - hs[i-1]).abs
    next
  end
  step1 = (hs[i] - hs[i-1]).abs + dp[i-1]
  step2 = (hs[i] - hs[i-2]).abs + dp[i-2]
  dp[i] = step1 < step2 ? step1 : step2
end
p dp[-1]

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

int main() {
    int N;
    cin >> N;
    bool ans=false;
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            if(i*j==N){
                ans=true;
                break;
            }

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

    }



Measured memory_bytes: 3532
import java.awt.geom.*;
import java.util.*;
public class Main {
	
	boolean [] used;
	boolean flg, dup;
	int n,w,h, deepsize;
	int [][] data, ans;
	int [] hash;
	C[][] cand;
	P [] point;
	
	class C{
		HashSet<Integer> list;

		public C(HashSet<Integer> list) {
			this.list = list;
		}
	}
	
	class P{
		int x,y;

		public P(int x, int y) {
			this.x = x;
			this.y = y;
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			w = sc.nextInt();
			h = sc.nextInt();
			n = sc.nextInt();
			if((w|h|n) == 0) break;
			hash = new int[n+1];
			deepsize = n;
			for(int i = 0; i < n; i++){
				int b = sc.nextInt();
				int k = sc.nextInt();
				hash[b] = k;
				if(k == 1) deepsize--;
			}
			data = new int[h][w];
			point = new P[n+1];
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					data[i][j] = sc.nextInt();
					if(data[i][j] > 0){
						point[data[i][j]] = new P(j, i);
					}
				}
			}
			
			used = new boolean[n+1];
			flg = false;
			dup = true;
			ans = new int[h][w];
			dfs(1);
			if(flg && dup){
				for(int i = 0; i < h; i++){
					System.out.print(ans[i][0]);
					for(int j = 1; j < w; j++){
						System.out.print(" " + ans[i][j]);
					}
					System.out.println();
				}
			}
			else{
				System.out.println("NA");
			}
		}
	}
	

	private void dfs(int deep) {
		if(deep == n + 1){
			if(flg){
				dup =false;
				return;
			}
			flg = true;
			for(int i = 0; i < h; i++){
				ans[i] = data[i].clone();
			}
			return ;
		}
		if(hash[deep] == 1){
			dfs(deep+1);
			return ;
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(data[i][j] != 0 && data[i][j] != deep) continue;
				
				for(int k = i; k < h; k++){
					for(int l = j; l < w; l++){
						int dis = calcdis(j, i, l, k);
						if(used[deep]) continue;
						if(dis == hash[deep]){
							
							boolean res = check(j,i,l,k, deep);
							if(! res) continue;
							set(j,i,l,k, deep);
							used[deep] = true;
							dfs(deep + 1);
							used[deep] = false;
							set(j,i,l,k,0);
							data[point[deep].y][point[deep].x] = deep;
						}
					}
				}
				
			}
		}
		
		
	}
	
	private void disp(){
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				System.out.print(data[i][j] + " ");
			}
			System.out.println();
		}
	}


	private void set(int x1, int y1, int x2, int y2, int num) {
		
		for(int i = y1; i <= y2; i++){
			for(int j = x1; j <= x2; j++){
				data[i][j] = num;
			}
		}
	}


	private boolean check(int x1, int y1, int x2, int y2, int num) {
		boolean issameC = false;
		for(int i = y1; i <= y2; i++){
			for(int j = x1; j <= x2; j++){
				if(data[i][j] == num){
					issameC = true;
				}
				else if(data[i][j] != 0){
					return false;
				}
			}
		}
		if(issameC) return true;
		return false;
	}


	private int calcdis(int x1, int y1, int x2, int y2) {
		int res = (Math.abs(x1 - x2) + 1) * (Math.abs(y1 - y2) + 1);
		return res;
	}


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

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

int main() {
  int n;
  std::cin >> n;
  std::map<std::string, int> m;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    std::string s;
    std::cin >> s;
    std::sort(s.begin(), s.end());
    ans += m[s];
    ++m[s];
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 11136
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;

uint64_t comb(uint64_t n, uint64_t k)
{
    uint64_t result = 1;
    for(uint64_t i=1; i<=k; i++)
    {
        result *= n--;
        result /= i;
    }
    return result;
}

int counter(int n, int k, int size, string &N)
{
    int result=0, digit=(N[size-n]-'0');
    if(n==0)
    {
        if(k==0) result = 1;
        else result = 0;
    }
    else
    {
        if(k==0) result=1;
        else
        {
            if(digit==0) result = counter(n-1, k, size, N);
            else
            {
                result += pow(9, k)*comb(n-1, k);
                result += (digit-1)*pow(9, k-1)*comb(n-1, k-1);
                result += counter(n-1, k-1, size, N);
            }
        }
    }
    return result;
}

int main()
{
    string N;
    int k;
    cin >> N >> k;
    int len=N.length();

    cout << counter(len, k, len, N) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(0,  min(b,d) - max(a,c)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int a,b;cin>>a>>b;
    cout<<6-a-b;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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


void oneCase () {
    int n;
    cin >>n;
    vector<int> a(n);
    for (auto& e : a) {
        cin >> e;
    }
    vector<int> order(n);
    for (int i = 0; i < n; ++i) {
        order[i] = abs((n - i - 1 - i));
    }
    sort(order.begin(), order.end());
    sort(a.begin(), a.end());
    if (a != order) {
        cout << 0 << "\n";
        return;
    }
    int mod = 1e9 + 7;
    ll count = 1;
    for (int i = 0; i * 2 + 1 < n; ++i) {
        count = (count * 2) % mod;
    }
    cout << count << "\n";



}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
vector<lint> frac(200001);
lint N;
struct Node;
vector<Node> V;
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
struct Node {
  int idx;
  vector<int> nbr;
  bool vst = false;
  lint dp1 = 1;
  lint size = 1;
  lint dp2 = 1;
  void dfs1() {
    vst = true;
    for(int x : nbr) {
      if(!V[x].vst) {
        V[x].dfs1();
        size += V[x].size;
        dp1 = dp1 * V[x].dp1 % MOD * power(frac[V[x].size], MOD-2, MOD) % MOD;
      }
    }
    dp1 = dp1 * frac[size-1] % MOD;
  };
  void dfs2(lint p) {
    vst = true;
    dp2 = dp1 * power(frac[size-1], MOD-2, MOD) % MOD * frac[N-1] % MOD * power(frac[N-size], MOD-2, MOD) % MOD * p % MOD;
    for(int x : nbr) {
      if(!V[x].vst) {
        lint pnext = dp2 * power(frac[N-1], MOD-2, MOD) % MOD * frac[N-1-V[x].size] % MOD * frac[V[x].size] % MOD * power(V[x].dp1, MOD-2, MOD) % MOD;
        V[x].dfs2(pnext);
      }
    }
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  REP(i, N) {
    V.emplace_back();
    V[i].idx = i;
  }
  REP(i, N-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    V[a].nbr.push_back(b);
    V[b].nbr.push_back(a);
  }
  frac[0] = 1;
  FOR(i, 1, 200001) {
    frac[i] = frac[i-1] * i % MOD;
  }
  V[0].dfs1();
  REP(i, N) V[i].vst = false;
  V[0].dfs2(1);
  REP(i, N) cout << V[i].dp2 << "\n";
}

Measured memory_bytes: 24420
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    int in;
    char S[1000];
    
    while(NULL!=gets(S)){
    
    while(1){
        
        bool f = false;
        
        for(int i=0;S[i]!='\0';i++){
            if('a'<=S[i] && S[i]<='y'){
                S[i]++;
            }else if(S[i]=='z'){
                S[i]='a';
            }
            
            if(i>=2){
                if(S[i-2]=='t' && S[i-1]=='h' && S[i]=='e')
                    f=true;
            }
            if(i>=3){
                if(S[i-3]=='t' && S[i-2]=='h')
                    if((S[i-1]=='i' && S[i]=='s') || (S[i-1]=='a' && S[i]=='t'))
                        f=true;
            }
        }
        
        if(f) break;
    }
    
    printf("%s\n",S);
    }
    
    return 0;
}

Measured memory_bytes: 1088
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc185
{
    class Program
    {
        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc185C();
        }

        public static void solve_abc185C()
        {
            int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int a = ab[0];
            int b = ab[1];
            bool ok = false;
            int x = 0;
            for (int i = 1; i <= 10000; i++)
            {
                if ((i * 8) / 100 == a && (i * 10) / 100 == b)
                {
                    ok = true;
                    x = i;
                    break;
                }
            }
            if (ok)
            {
                Console.WriteLine(x);
            }
            else
            {
                Console.WriteLine(-1);
            }
        }

        public static void solve_abc185B()
        {
            long[] nab = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long n = nab[0];
            long a = nab[1];
            long b = nab[2];
            long x = n / (a + b);
            long xr = n % (a + b);
            Console.WriteLine(a > 0 ? x * a + Math.Min(xr, a) : 0);
        }

        public static void solve_abc185A()
        {
            string s = Console.ReadLine();

            if (s.Contains('A') && s.Contains('B'))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
s = raw_input()
p = "ABC"
used = set()

while s != p:
    idx = 0
    c = [0]*3
    while idx < len(s):
        if idx+3 <= len(s) and s[idx:idx+3] == p:
            idx += 3
        else:
            c[p.index(s[idx])] += 1
            idx += 1
    if sum(e == 0 for e in c) != 1 or sum(c) == len(s):
        print "No"
        exit(0)
    s = s.replace("ABC", p[[i for i in [0,1,2] if c[i]==0][0]])
print "Yes"

Measured memory_bytes: 6456
//Name : Rupa Dey
  //Date : 19 September 2020
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
#define ll long long
#define d double
#define ld long double
#define vi vector<int>
#define vul vector<ull>
#define vl vector<ll>
#define pb push_back
#define si set<int>
#define sl set<ll>
#define yes cout<<"YES\n"<<endl
#define no cout<<"NO\n"<<endl
#define ys cout<<"Yes\n"<<endl
#define n0 cout<<"No\n"<<endl
#define test cin>>t; while(t--)
#define for(i,a,n) for(i=a;i<n;i++)
#define mp make_pair
#define ft first
#define sc second
#define gp ' ';
#define MAX 9999999
#define MOD 1000000007
#define nd endl
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,i,j,k,cnt=0;
    cin>>n;
    int a[n][2];
    for(i,0,n)
    {
        for(j,0,2) cin>>a[i][j];
    }
     for(i,0,n)
    {
        for(j,0,2)
        {
            if((a[i][0]==a[i][1]) && (a[i+1][0]==a[i+1][1]) && (a[i+2][0]==a[i+2][1]))
              cnt=1;
            else
                continue;
        }
    }
   // cout<<cnt<<nd;
   if(cnt==1) ys;
   else n0;

}
//hare krishna...
//hey gobindo kripa koro......
//only gobindo exists..^..


Measured memory_bytes: 3640
def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    D = []
    for a in A:
        for b in B:
            D.append(a + b)

    D.sort(reverse=True)
    E = []
    for i in range(min(len(D),K)):
        for c in C:
            E.append(D[i] + c)

    E.sort(reverse=True)

    for i in range(K):
        print(E[i])
        

main()

Measured memory_bytes: 148364
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long L = sc.nextLong();
		long R = sc.nextLong();

		if (R - L >= 2019) {
			System.out.println(0);
			return;
		}

		long ans = Long.MAX_VALUE;
		for (long i = L; i < R; i++) {
			long tmp =0;
			for (long j = i+1; j <= R; j++) {
				tmp=(i*j)%2019;
				ans = Math.min(ans, tmp);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<stdio.h>
#define N 100
main()
{
  int A[N],i,v,j,n,x;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
      if(i==n-1)printf("%d",A[i]);
      else printf("%d ",A[i]);
      }
  printf("\n");
  for(i=1;i<=n;i++)
    {
      if(i>1){   
for(x=0;x<n;x++)
	{
	  if(x==n-1)printf("%d",A[x]);
	  else printf("%d ",A[x]);
	}
      printf("\n");
      }
    
  v=A[i];
  j=i-1;
  while(j>=0&&A[j]>v)
    {
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
     
    }
    }
  return 0;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int n,k;

ll a[100001];
ll rui[100002];
ll rui2[100002];
int main(){
  cin >> n>>k;
  rui[0] = 0ll;
  rui2[0] = 0ll;
  FOR(i,1,n+1){
    cin >> a[i];
    rui[i] = rui[i-1]+a[i];
    rui2[i] = rui2[i-1] + max(0ll,a[i]);
  }
  ll ma = max(0ll,rui[k]) + rui2[n]-rui2[k];
  FOR(i,1,n-k+1){
    ll t = max(0ll,rui[i+k]-rui[i]);
    ll l = rui2[i];
    ll r = rui2[n]-rui2[i+k];
    //cout << t << " " << l << " " << r <<endl;
    ma = max(ma,t+l+r);
  }
  cout <<ma <<endl;
}


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

using namespace std;

int main()
{
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	
	int anum = 0, bnum = 0;
	for (int i = 0; i < n; i++) {
		switch (s[i]) {
		case 'a':
			if (a + b > anum + bnum) {
				cout << "Yes" << endl;
				anum++;
			}
			else {
				cout << "No" << endl;
			}
			break;
		case 'b':
			if (a + b > anum + bnum && bnum < b) {
				cout << "Yes" << endl;
				bnum++;
			}
			else {
				cout << "No" << endl;
			}
			break;
		case 'c':
			cout << "No" << endl;
			break;
		}
	}

	return 0;
}

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

int main(){
    string t;
    cin>>t;
    rep(i,t.size()){
        if(t[i]=='?'){
            t[i] = 'D';
        }
    }
    cout << t << endl;

}



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

const int MOD = 1e9 + 7;

void add(int& a, int b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

int mul(int a, int b) {
	return 1LL * a * b % MOD;
}

int pow(int a, int b) {
	if (b == 1) return a;
	int q = pow(a, b/2);
	q = mul(q, q);
	if (b%2) {
		q = mul(a, q);
	}
	return q;
}

int inv(int a) {
	return pow(a, MOD-2);
}

const int N = 2e6;

int fact[N+1];

int choose(int n, int k) {
	assert(n <= N);
	assert(k <= n);
	return mul(fact[n], mul(inv(fact[k]), inv(fact[n-k])));
}

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

	fact[0] = 1;
	for (int i = 1; i <= N; i++) {
		fact[i] = mul(i, fact[i-1]);
	}

	int x, y;
	cin >> x >> y;

	if (2*y < x || (2*y - x)%3 != 0) {
		cout << 0 << endl;
		return 0;
	}
	int a = (2*y - x)/3;
	if (y < 2*a) {
		cout << 0 << endl;
		return 0;
	}
	int b = y - 2*a;

	cout << choose(a+b, a) << endl;

	return 0;
}



Measured memory_bytes: 8064
n = int(input())
d = {
    "AC": 0, 
    "WA": 0, 
    "TLE": 0, 
    "RE": 0, 
}
s = [input() for _ in range(n)]
for x in s:
    d[x] += 1

for k in d:
    print(k, "x", d[k])


Measured memory_bytes: 79212
N = int(input())
A = []
W = [[] for i in range(N)]
for i in range(N):
    a = int(input())
    A.append(a)
    for j in range(a):
        a, b = input().split()
        W[i].append((int(a) - 1, int(b)))

L = 2 ** N
max_cnt = 0
for G in range(L):
    b = 1
    n = 0
    ok = True
    while n < N:
        if G & b > 0:
            for i in range(A[n]):
                no = W[n][i][0]
                hl = W[n][i][1]
                c = 1 << no
                if (c & G > 0 and hl == 0) or (c & G == 0 and hl == 1):
                    ok = False
                    break

            if not ok:
                break
        b <<= 1
        n += 1
    if ok:
        cnt = bin(G)[2:].count('1')
        max_cnt = max(cnt, max_cnt)

print(max_cnt)






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

int main() {
	int N, X;
	cin >> N >> X;
	int min_m = 1000;
	int num = 0;
	for (int i = 0; i < N; i++) {
		int m;
		cin >> m;
		X -= m;
		num++;
		if (min_m > m) min_m = m;
	}
	num += X / min_m;
	cout << num;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;

int main()
{
	int s;
	cin >> s;
	if ((s % 100 == 0 || s % 100 > 12) && (s / 100 == 0 || s / 100 > 12)) {
		cout << "NA" << endl;
	} else if (s % 100 == 0 || s % 100 > 12) {
		cout << "MMYY" << endl;
	} else if (s / 100 == 0 || s / 100 > 12) {
		cout << "YYMM" << endl;
	} else {
		cout << "AMBIGUOUS" << endl;
	}

	return 0;
}


Measured memory_bytes: 256