akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  string n;
  cin >> n;
  cout << (n[0]==n[2]?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void push1(int *a,int x);
int pop(int *a);
int isEmpty();
int top1;
struct stack2{
  int index;
  int area;
};
int ppcnt;
void push2(struct stack2 *a, int x1,int x2);
int top2;
int main()
{
  int n,r,i=0,k=0,all=0,st1[20001],c,ind,sub;
  struct stack2 st2[10001];
  char sente[20001];
  top1=0;
  top2=0;
  st2[0].index=-1;
  scanf("%s",sente);
  for(ind=0; ;ind++){
    if(sente[ind]=='\0')break;
    if(sente[ind-1]=='/' && sente[ind]!='/')ppcnt=sub;
    if(sente[ind]=='\\')push1(st1,ind);
    else if(sente[ind]=='/'){
      sub=pop(st1);
      if(sub!=-1)push2(st2,ind,sub);
    }
  }
  for(r=1;r<=top2;r++){
    all+=st2[r].area;
  }
  printf("%d\n",all);
  if(top2==0)printf("%d",top2);
  else {printf("%d ",top2);
    for(r=1;r<=top2;r++){
      printf("%d",st2[r].area);
      if(r!=top2)printf(" ");
    }
  }
  printf("\n");
  return 0;
}
void push1(int *a, int x){
  top1=top1+1;
  a[top1]=x;
  //printf("stack1  %d\n",a[top1]);
}
void push2(struct stack2 *a, int x1,int x2){
  int i,k=0;;
  if((a[top2].index<x2)){
    top2=top2+1;
    a[top2].index=x2;
    a[top2].area=x1-x2;
    //printf("index %d ",a[top2].index);
    //printf("area %d,top(up) %d\n",a[top2].area,top2);
  }else{
    a[top2].area+=(x1-x2);
    k = top2;
    for(i=top2-1;i>=1;i--){
      if(a[i].index > x2){
	a[top2].area += a[i].area;
	k = i;
      }
    }
    a[k].index = a[top2].index;
    a[k].area = a[top2].area;
    top2 = k;
    //printf("index %d ",a[top2].index);
    //printf("area %d, top(stay) %d\n",a[top2].area,top2);
  }
}
int pop(int *a){
  if(isEmpty()==1){
    return -1;
  }else{
    top1=top1-1;
    //printf("pop %d ",a[top1+1]);
    return a[top1+1];
  }
}
int isEmpty(){
  if(top1==0){
    return 1;
  }else{
    return 0;
  }
}




Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    vector<vector<int>> num(10,vector<int>(10,0));
    for(int i=1; i<=n; i++){
        int r = i%10;
        int l = i;
        while(l>=10)l/=10;
        num[r][l]++;
    }
    ll ans = 0;
    for(int i=1; i<=n; i++){
        int r = i%10;
        int l = i;
        while(l>=10)l/=10;
        ans+=num[l][r];

    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import sys
import math

#https://atcoder.jp/contests/agc008/submissions/15248942
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()

if N%2 == 0:
    print(N)
else:
    print(N*2)

Measured memory_bytes: 9136
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
	int a, b, sum;
	while (cin >> a, cin >> b){
		sum = a + b;
		for (int i = 0; i < 10; ++i){
			if (sum == 0){
				cout << i << endl;
				break;
			}
			sum /= 10;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int ans[200001];
int main(){
   int N;
   cin >> N;
   int A[N+1];
   vector<int> edge[N+1];
   memset(ans,0,sizeof(ans));
   for(int i = 1; i < N; i++){
      cin >> A[i];
      A[i]--;
      edge[A[i]].push_back(i);
   }
   for(int i = 0 ; i < N; i++){
      cout << edge[i].size() << endl;
   }
   return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

vector<int> g[500];
bool visited[500];
int main() {
  int n,m;
  while(cin>>n>>m) {
    REP(i,n)g[i].clear();
    REP(i,m) {
      int a, b;
      cin >> a >> b;
      a--;b--;
      g[a].push_back(b);
    }
    memset(visited,0,sizeof(visited));
    int cnt = 0;
    REP(i,n) {
      if (!visited[i]) {
        cnt++;
        visited[i] = 1;
        queue<int> Q;
        Q.push(i);
        while(!Q.empty()) {
          int a = Q.front(); Q.pop();
          FOR(it, g[a]) {
            if (!visited[*it]) {
              visited[*it] = 1;
              Q.push(*it);
            }
          }
        }
      }
    }
    cout << m-n+cnt << endl;
  }
}

Measured memory_bytes: 1260
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
using namespace std;


int main(){
  long long a,b,c,k;
  cin>>a>>b>>c>>k;
  long long s,t,u;
  s=b-a;
  t=a-b;
  if(abs(b-a)>1e18){
      cout<<"Unfair"<<endl;
  }
  if(k%2==0){
      cout<<a-b<<endl;
  }
  else{
      cout<<b-a<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  vector<vector<int>> cnt(2, vector<int>(26, 0));
  rep(i, 2) {
    string s;
    cin >> s;
    rep(j, s.size()) { cnt[i][s[j] - 'a']++; }
  }

  vector<string> s2(2);

  rep(c, 26) {
    rep(j, cnt[0][c]) { s2[0].push_back(c + 'a'); }
  }
  rrep(c, 26) {
    rep(j, cnt[1][c]) { s2[1].push_back(c + 'a'); }
  }

  cout << (s2[0] < s2[1] ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}

int32_t main(){
	int n;
	cin>>n;
	int u = n / 1.08;
	for(int j = u - 1 ; j <= u+1 ; j ++){
		int p = j * 1.08;
		if(p == n){
			cout<< j << endl;
			return 0;
		}
	}
	cout<<":("<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a = [int(input()) for i in range(m)]
dp=[0]*(n+1)
if m==0:
  for i in range(n,-1,-1):
    if i==n or i==n-1:
      dp[i]=1
    else:
      dp[i]=dp[i+1]+dp[i+2]
  print(dp[0]%1000000007)
else:
  j=-1
  for i in range(n,-1,-1):
    if i==a[j]:
      if m>j*(-1):
        j-=1
    else:
      if i==n or i==n-1:
        dp[i]=1
      else:
        dp[i]=dp[i+1]+dp[i+2]
  print(dp[0]%1000000007)

Measured memory_bytes: 469756
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n-k) {
        if(a[i+k] > a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 4048
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    const int n = 50;
    cin >> k;
    cout << n << "\n";
    REP(i, n){
        ll a = i + k / n;
        if(i >= n - k % n){
            a++;
        }
        cout << a << " ";
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    char a , b;
    cin >> a >> b;
    if(int(a) < int(b)){
        cout << "<";
        return 0;
    }
    if(int(a) > int(b)){
        cout << ">";
        return 0;
    }
    cout << "=";
    return 0;


}

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

int main() {
  int N;
  cin >> N;
  vector <double> x(N);
  vector <string> u(N);
  for(int i=0;i<N;i++){
    cin >> x.at(i) >> u.at(i);
  }
  double ans = 0;
  for(int j=0;j<N;j++){
    if(u.at(j) == "JPY"){
      ans += x.at(j);
    }
    else{
      ans += x.at(j)*380000;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> ans(N+1, -1);
    int s[10010], c[10010];
    for(int i = 1; i <= M; ++i) cin >> s[i] >> c[i];
    for(int i = 1; i <= M; ++i){
        if( (ans[s[i]] != -1 && ans[s[i]] != c[i]) || (s[i] == 1 && c[i] == 0 && N > 1)){
            cout << -1 << endl;
            return 0;
        }
        else ans[s[i]] = c[i];
    }
    for(int i = 1; i <= N; ++i){
        if(ans[i] == -1){
            if(i == 1 && N > 1) ans[i] = 1;
            else ans[i] = 0;
        }
    }
    for(int i = 1; i <= N; ++i){
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3604
/*input
9
basic
c
cpp
php
python
nadesico
ocaml
lua
assembly
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 
#define INF 0x3f3f3f3f

set<string> cc; 
int32_t main(){
    IOS;
    string s;
    int n;
    cin >> n;
    string pre = ".";
    REP(i , 1 , n + 1){
        cin >> s;
        if(cc.count(s)) return cout << "No" << endl , 0;
        else {
            if(i != 1 && s[0] != pre.back()) return cout << "No" << endl , 0;
            cc.insert(s);
            pre = s;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>


int main()
{
	char str1[201], str2[101], str3[101];
	scanf("%s %s", str1, str2);

	strcpy(str3, str1);
	strcat(str1, str3);
	if (strstr(str1, str2) == NULL) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}

    return 0;
}



Measured memory_bytes: 2740
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s[101010];
int main()
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	scanf("%s",s);
	a+=b;
	for(int i=0;i<n;i++)
		if(s[i]=='a'&&a)
		{
			a--;
			printf("Yes\n");
		}
		else if(s[i]=='b'&&a&&b)
		{
			a--;
			b--;
			printf("Yes\n");
		}
		else
			printf("No\n");
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define MAX_V 1000
#define INF 999999
using namespace std;

typedef struct edge{
  int to,cap,rev;
}edge;
vector<edge> G[2*MAX_V+2];
int d[MAX_V][MAX_V];
bool used[MAX_V];
int n,m,cost;

void floyed(int n){
  for(int i=0;i<n;i++)d[i][i]=0;

  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  // cout << "result of floyed" << endl;
  // for(int i=0;i<n;i++){
  //   for(int j=0;j<n;j++){
  //     cout << d[i][j] << " ";
  //   }
  //   cout << endl;
  // }
 }

bool makeG(){
  memset(G,0,sizeof(G));
  memset(d,1,sizeof(d));
  if(scanf("%d%d%d",&n,&m,&cost)==EOF)return false;
  for(int i=0;i<m;i++){
    int to,from,cap;
    cin>>from>>to>>cap;
    d[from-1][to-1]=cap;
    d[to-1][from-1]=cap;
  }
  floyed(n);
  int bef[n],aft[n];
  for(int i=0;i<n;i++){
    cin>>bef[i];
  }
  for(int i=0;i<n;i++){
    cin>>aft[i];
   }
  for(int i=0;i<n;i++){
    for(int j=n;j<2*n;j++){
      if(d[i][j-n]<cost){
	G[i].push_back((edge){j,bef[i],G[j].size()});
	G[j].push_back((edge){i,0,G[i].size()-1});
      }
    }
  }
  for(int i=0;i<n;i++){
    G[2*n].push_back((edge){i,bef[i],G[i].size()});
    G[i].push_back((edge){2*n,0,G[2*n].size()-1});
  }
  for(int i=n;i<2*n;i++){
     G[i].push_back((edge){2*n+1,aft[i-n],G[2*n+1].size()});
    G[2*n+1].push_back((edge){i,0,G[i].size()-1});
  }
  return true;
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v] = true;
  for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to] && e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	G[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow= 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0) return flow;
    flow += f;
  }
}

int main(){
  while(makeG()!=false){
    // for(int i=0;i<2*n+2;i++){
    //   cout << i << ": ";
    //   for(int j=0;j<G[i].size();j++){
    // 	cout << "{" << G[i][j].to << "," << G[i][j].cap<<"} ";
    //   }
    //   cout << endl;
    // }
    // cout  << endl;
    int ans=max_flow(2*n,2*n+1);
    cout << ans << endl;
  }
  return 0;
}

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

int N;
std::vector<int> a;
std::string s;

int dfs(int i, int k)
{
  if (i==N-1) {
    a.push_back(k+(s[i]=='.'));
    if (s[i]=='.') return 1;
    else return 0;
  }
  else {
    int l = dfs(i+1, k+(s[i]=='#'));
    a.push_back(k+(s[i]=='.')+l);
    return l + (s[i]=='.');
  }
}

int main()
{
  std::cin >> N;
  std::cin >> s;

  if (dfs(0, 0) == N) a[0] = 0;

  int n = 0;
  int i = 0;
  while (s[i]=='#') i++, n++;
  while (s[i]=='.') i++;
  if (i==N) a[0] = (n < (N-n)) ? n : (N-n);

  std::sort(a.begin(), a.end());

  std::cout << a[0] << std::endl;
  return 0;
}


Measured memory_bytes: 11004
#include <bits/stdc++.h>
using namespace std;
int n, k;
long long tot = 0;
int main()
{
#ifdef _noname
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> n >> k;
	for (int b = k + 1; b <= n; b++)
	{
		int x = n / b, y = n % b;
		tot += 1LL * x * (b - k);
		tot += y >= k? y - k + 1 : 0;
	}
	if (!k) tot -= n;
	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = list(map(int,input().split()))

s = []
c = []
for i in range(M):
    x1,y1=[int(i) for i in input().split()]
    s.append(x1)
    c.append(y1)

sum = 0
flag = True

if(N == 1 and M == 0):
  print(0)
  exit()

for i in range(M):
  if(s[i] == 1 and c[i] == 0 and N != 1):
    print(-1)
    exit()
  for j in range(M):
    if(s[i] == s[j] and c[i] != c[j]):
      print(-1)
      exit()

kisyutu = []

for i in range(M):
    if not(s[i] in kisyutu):
      sum += c[i] * (10 ** (N - s[i]))
      kisyutu.append(s[i])
if not(1 in s):
  sum += 10 ** (N - 1)
print(sum)



Measured memory_bytes: 3064
n = gets.to_i
as = []
bs = []
n.times do |i|
  a, b = gets.split(" ").map(&:to_i)
  as << a
  bs << b
end

as.sort!
bs.sort!
i = n / 2
if n % 2 == 0
  p bs[i-1] + bs[i] - (as[i-1] + as[i]) + 1
else
  p bs[i] - as[i] + 1
end

Measured memory_bytes: 20344
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	ll real_ans = 1e18;
	for (int i = 0; i < (1<<(n-1)); i++){
		vector<bool> tower(n-1);
		int coun = 0; 
		for (int j = 0; j < n-1; j++){
			if (i & (1<<j)){
				tower[j] = true;
				coun++;
			}else{
				tower[j] = false;
			}
		}
		if (coun < k-1) continue;
		ll ans = 0;
		int tmp_max = a[0];
		for (int j = 0; j < n-1; j++){
			if (tower[j] == false){
				tmp_max = max(a[j+1], tmp_max);
			}else{
				ans += max(tmp_max - a[j+1] + 1, 0);
				tmp_max = max(tmp_max + 1, a[j+1]);
			}
		}
		real_ans = min(ans, real_ans);
	}
	cout << real_ans << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a;
  for (int i=0; i<n; i++) {
    int input;
    cin >> input;
    a.push_back(input);
  }
  //sort(a.begin(), a.end());

  int rates[9];
  for (int i=0; i<9; i++) {
    rates[i] = 0;
  }

  for (int i=0; i<(int)a.size(); i++) {
    int r = a[i];
    if (r < 400) rates[0]++;
    if (480<= r && r < 800) rates[1]++;
    if (800<= r && r < 1200) rates[2]++;
    if (1200<= r && r < 1600) rates[3]++;
    if (1600<= r && r < 2000) rates[4]++;
    if (2000<= r && r < 2400) rates[5]++;
    if (2400<= r && r < 2800) rates[6]++;
    if (2800<= r && r < 3200) rates[7]++;
    if (3200<= r) rates[8]++;
  }

  int cnt=0;
  for (int i=0; i<8; i++) {
    if (rates[i] != 0) {
      cnt++;
    }
  }

  int min, max;
  min = ((cnt==0)?1:cnt);
  max = ((cnt==0)?rates[8]:cnt+rates[8]);
  printf("%d %d\n", min, max);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define Fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define deb(x) cout<<#x<<" "<<x<<endl;
#define all(v) v.begin(),v.end()
#define endl '\n'
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void judge() {
#ifndef ONLINE_JUDGE
	FILE_READ_IN
	FILE_READ_OUT
#endif
}

int main() {
	Fast;
	int t = 1;
	judge();
	// cin >> t;
	while (t--) {
		list<int> l;
		int n, k;
		cin >> n >> k;
		int a[n];
		for (int i = 0; i < n; i++)cin >> a[i];
		for (int i = 0; i < k; i++) {
			l.push_back(a[i]);
		}
		for (int i = k; i < n; i++) {
			l.push_back(a[i]);
			if (l.front() < l.back())cout << "Yes" << endl;
			else {
				cout << "No" << endl;
			}
			l.pop_front();
		}
	}
}

Measured memory_bytes: 10688
#include<stdio.h>
int main(void){
	int x,y,temp;
	while(1){
		scanf("%d %d",&x,&y);
		if (x==0 && y==0){
			break;
		}
		if (x>y){
			temp=x;
			x=y;
			y=temp;
		}
		printf("%d %d\n",x,y);
	}
return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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





///////////////////////////


int main() {
	ll N;
	ll c[5] = {};

	cin >> N;
	repn(i, N) {
		string S;
		cin >> S;
		if (S[0] == 'M') { c[0]++; }
		if (S[0] == 'A') { c[1]++; }
		if (S[0] == 'R') { c[2]++; }
		if (S[0] == 'C') { c[3]++; }
		if (S[0] == 'H') { c[4]++; }
	}

	ll ans = 0;

	rep(i, 5) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += c[i] * c[j] * c[k];
			}
		}
	}

	cout << ans;

	system("PAUSE");

}


Measured memory_bytes: 504
using System;

class A
{
	static void Main()
	{
		var k = Array.ConvertAll(Console.ReadLine().Split(), int.Parse)[1] - 1;
		var s = Console.ReadLine().ToCharArray();
		s[k] = char.ToLower(s[k]);
		Console.WriteLine(new string(s));
	}
}


Measured memory_bytes: 11092
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextLong()
  val b = sc.nextLong()
  val c = sc.nextLong()
  val d = sc.nextLong()

  val list = mutableListOf<Long>()
  list.add(a * c)
  list.add(a * d)
  list.add(b * c)
  list.add(b * d)

  println(list.max()!!)

}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string s;
  cin >> s;
  cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[200000];
Pll a[200000], b[200000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<Edge>>vec;
vector<edge>ed;
vector<LL>v;
map<LL,LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i].fir >> a[i].sec;
	}
	last = INF;
	rep(i, m) {
		cin >> b[i].fir >> b[i].sec;
		if (last <= b[i].sec) {
			i--, m--;
		}
		else last = b[i].sec;
	}
	rep(i, n) {
		if (a[i].fir < b[0].fir) {
			ans += a[i].sec;
			first = i+1;
		}
		else break;
	}
	b[m].first = INF;
	priority_queue<LL>pq;
	rep(i, m) {
		for (int j = first; j < n; j++) {
			if (b[i + 1].fir > a[j].fir) {
				pq.push(a[j].sec);
				first = j + 1;
			}
			else break;
		}
		for (int j = 0; j < (i+1==m?b[i].sec-1:b[i ].sec - b[i+ 1].sec); j++) {
			if (pq.empty())break;
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 5504
import heapq
n,m = map(int,input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)

for i in range(m):
    p = heapq.heappop(a)*(-1)
    p //= 2
    heapq.heappush(a,-p)
print(-sum(a))

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

int main() {
    int a, b, c, k; cin >> a >> b >> c >> k;
    
    if(a >= k) {
        cout << k;
    }else if(a + b >= k) {
        cout << a;
    }else{
        cout << a - (k - a - b);
    }
    
    return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = long long;
using vint = vector<int>;

void Main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        if (1 <= i && i <= 9) ++ans;
        if (100 <= i && i <= 999) ++ans;
        if (10000 <= i && i <= 99999) ++ans;
    }
    cout << ans << endl;
}

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


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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int h,w;
  cin>>h>>w;
  auto a=make_v<Int>(h,w);
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      cin>>a[i][j];
  auto dp=make_v<Int>(h,w);
  fill_v(dp,0);
  Int ans=0;
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(a[i][j]) continue;
      if(i==0||j==0) dp[i][j]=1;
      else dp[i][j]=min({dp[i-1][j-1],dp[i-1][j],dp[i][j-1]})+1;
      chmax(ans,dp[i][j]);
    }
  }
  cout<<ans*ans<<endl;
  return 0;
}



Measured memory_bytes: 33440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;

struct FenwickTree {
  vector<int> tree;
  FenwickTree(int n) : tree(n+1) {}

  int sum(int pos) {
    ++pos;
    int ret = 0;
    while(pos > 0) {
      ret += tree[pos];
      pos &= (pos - 1);
    }
    return ret;
  }

  void add(int pos, int val) {
    ++pos;
    while(pos < tree.size()) {
      tree[pos] += val;
      pos += (pos & -pos);
    }
  }
};

int n, m;
string s;

int main(void) {
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  cout.tie(NULL);
  //freopen("in.txt", "r", stdin);
  cin >> n >> m;
  cin >> s;
  int maxLen = 0;
  int len = 0;
  rep(i,0,n+1) {
    if(s[i] == '1') {
      len++;
    } else {
      maxLen = max(maxLen, len);
      len = 0;
    }
  }
  if(maxLen >= m) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> ret;
  for(int i = n; i >= 0; ) {
    if(i <= m) {
      ret.pb(i);
      break;
    }

    int x = m;
    while(s[i-x] == '1') {
      x--;
    }
    i = i-x;
    ret.pb(x);
  }
  reverse(all(ret));
  rep(i,0,sz(ret)) {
    cout << ret[i] << ' ';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1096
object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)
	
	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit) {
		if (start <= end) {
			f(start)
			loop(start + 1, end)(f)
		}
	}
	
	val n, m, k = sc.nextInt
	
	val friend, blocked = Array.fill(n+1)(0)
	val uf = UnionFind(1 to n)
	
	Seq.fill(m)((sc.nextInt, sc.nextInt)) foreach { case (a, b) =>
		uf.unite(a, b)
		friend(a) = friend(a) + 1
		friend(b) = friend(b) + 1
	}
	
	Seq.fill(k)((sc.nextInt, sc.nextInt)) foreach { case (c, d) =>
		if (uf.same(c,d)) {
			blocked(c) = blocked(c) + 1
			blocked(d) = blocked(d) + 1
		}
	}
 
	loop(1, n) { i =>
		pw.print( (uf.size(i) - 1 - friend(i) - blocked(i)).toString + " " )
	}
	pw.flush()
}
 
case class UnionFind[T](seq: Seq[T]) {
	import scala.collection.mutable.Map
	private[this] val par: Map[T, T] = Map[T,T](seq.map(elem => elem -> elem): _*)
	private[this] val sz: Map[T, Int] = Map[T, Int](seq.map(elem => elem -> 1): _*)
 
	@scala.annotation.tailrec
	private[this] def find(t: T, acc: Seq[T] = Nil): T = {
		val p = par(t)
		if (p == t) {acc foreach { par(_) = t }; t} else find(p, p +: acc)
	}
 
	def unite(a: T, b: T): Unit = {
		val pa = find(a)
		val pb = find(b)
		
		if (pa == pb) return
		
		if (sz(pa) <= sz(pb)) {
			par(pa) = pb
			sz(pb)  = sz(pa) + sz(pb)
		} else {
			par(pb) = pa
			sz(pa)  = sz(pa) + sz(pb)
		} 
	}
 
	def same(a: T, b: T) = find(a) == find(b)
	
	def size(a: T) = sz(find(a))
}


Measured memory_bytes: 141340
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100001;
int main()
{
  long long h,sum=0;
  int n,a[MAXN];
  cin>>h>>n;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  if(sum<h) cout<<"No"<<endl;
  if(sum>=h) cout<<"Yes"<<endl;
  return 0;
  
  
  
  
}  

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
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&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  ll X = nextLong();

  ll ans = 0;
  ans += (X / 500) * 1000;
  X %= 500;
  ans += (X / 5) * 5;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

string s[510];
bool black[510];
const int inf=1<<20;

int main(void){
	int n;
	cin >> n;
	rep(i,n) cin >> s[i];

	int ans=-1;
	rep(i,n)rep(j,n) if(s[i][j]=='#') ans=inf;

	if(ans==-1){
		cout << -1 << endl;
		return 0;
	} 
	
	rep(j,n){
		black[j]=true;
		rep(i,n) if(s[i][j]=='.') black[j]=false;
	}

	
	rep(i,n){
		int cost=0;
		rep(j,n) if(s[i][j]=='.') cost++;
		if(s[i][i]=='.'){
			bool add=true;
			rep(j,n) if(s[j][i]=='#') add=false; 
			if(add) cost++;
		}
		rep(j,n) cost+=1-black[j];
		chmin(ans,cost);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <set>

using namespace std;

int mex[100001];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    mex[0] = 0;
    for (int i = 1; i <= k; i++) {
        set<int> st;
        for (int j = 0; j < n; j++) if (i >= a[j]) st.insert(mex[i - a[j]]);
        for (int j = 0; j < 101; j++) if (st.find(j) == st.end()) {
            mex[i] = j;
            break;
        }
    }
    cout << (mex[k] != 0 ? "First" : "Second");
    return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
MOD = 10 ** 9 + 7

min_lis = [0] * (N + 2)
max_lis = [0] * (N + 2)

for i in range(1, N + 2):
    min_lis[i] = min_lis[i - 1] + (i - 1)
    max_lis[i] = max_lis[i - 1] + (N - i + 1)

answer = 0
for k in range(K, N + 2):
    answer += max_lis[k] - min_lis[k] + 1
print(answer % MOD)

Measured memory_bytes: 30168
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
       string[] str = Console.ReadLine().Split(' ');
        int A = int.Parse(str[0]);
        int B = int.Parse(str[1]);
        int C = int.Parse(str[2]);
        int D = int.Parse(str[3]);
        sb.Append(Math.Max(A*B,C*D)+"\n");
    }
}

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

int main() {
  int a;
  
  cin >> a;
  
  int s1 = a/100;
  a = a%100;
  int s2 = a/10;
  a = a%10;
  int s3 = a;
  
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int A, B, C, D, E, F;

bool create_water(int g) {
    bool res = false;
    int amax = F / (A * 100);
    int bmax = F / (B * 100);
    
    rep(a, amax + 1) {
        rep(b, bmax + 1) {
            if ((a * A * 100 + b * B * 100) == g) {
                res = true;
                break;
            }
        }
    }
    
    return res;
}

bool create_sugar(int g) {
    bool res = false;
    int cmax = F * E / 100 / C;
    int dmax = F * E / 100 / D;
    
    rep(c, cmax + 1) {
        rep(d, dmax + 1) {
            if ((c * C + d * D) == g) {
                res = true;
                break;
            }
        }
    }
    
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> A >> B >> C >> D >> E >> F;
    double score = -1;
    int answ = 0, anss = 0;
    double limit_per = 100.0 * E / (100.0 + E);
    
    rep(s, F + 1) {
        rep(w, F - s + 1) {
            if (!create_water(w)) {
                continue;
            }
            
            if (!create_sugar(s)) {
                continue;
            }
            
            double ts = 100.0 * s / (s + w);
            
            if (ts > limit_per) {
                continue;
            }
            
            if (ts > score) {
                score = ts;
                answ = w;
                anss = s;
            }
        }
    }
    
    cout << (answ + anss) << " " << anss << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
x=s
while(1):
  a=s.find('()')
  if a==-1:
    break
  s=s[:a]+s[a+2:]
for i in range(len(s)):
  if s[i]==')':
    x='('+x
  else:
    x=x+')'
print(x)

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n], b[n], A[n], B[n];
    int S=0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    A[0] = a[0];
    for (int i = 1; i < n; i++)
    {
        A[i] = A[i-1] + a[i];
    }
    B[n-1] = b[n-1];
    for (int i = n-2; i >= 0; i--)
    {
        B[i] = B[i+1] + b[i];
    }
    for (int i = 0; i < n; i++)
    {
        S = max(S,A[i]+B[i]);
    }
    cout << S;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
int main()
{
    int n;
    long long int ans,first=2,last=1;
    scanf("%d",&n);
    bool flag=0;
    if(n==1){
        printf("1\n");
    }
    else{
        for(int i=1; i<n; i++){
            ans=first+last;
            first=last;
            last=ans;
        }
        flag=1;
    }
    if(flag){
        printf("%lld\n",ans);
    }
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9
#define LINF (ll)4e18
#define MOD (ll)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

set<int> edge[10];

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

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        edge[a].insert(b);
        edge[b].insert(a);
    }

    vector<int> p;

    REP(i, 2, n + 1) {
        p.push_back(i);
    }

    int ans = 0;

    do {
        bool can = true;

        if (!edge[1].count(p[0])) can = false;

        rep(i, n - 2) {
            if (!edge[p[i]].count(p[i + 1])) {
                can = false;
                break;
            }
        }

        if (can) ans++;
    } while (NP(p));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N[4];
	cin >> N[0] >> N[1] >> N[2] >> N[3];

	bool flat_N[4];
	flat_N[0] = false;//1
	flat_N[1] = false;//9
	flat_N[2] = false;//7
	flat_N[3] = false;//4

	for (int i = 0; i < 4; i++) {
		if (N[i] == 1) {
			flat_N[0] = true;
		}
		else if (N[i] == 9) {
			flat_N[1] = true;
		}
		else if (N[i] == 7) {
			flat_N[2] = true;
		}
		else if (N[i] == 4) {
			flat_N[3] = true;
		}
	}

	int count = 0;
	for (int i = 0; i < 4; i++) {
		if (flat_N[i]) {
			count++;
		}
	}

	if (count == 4) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}

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

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  int res=0;
  for(int i=0;i<=N;i++) {
    int a=i%10,b=i/10,c=i/100,d=i/1000,e=i/10000;
    int f=b%10,g=c%10,h=d%10,j=e%10;
    int s=a+f+g+h+j;
    if(s>=A && s<=B) res+=i;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) (v).begin(), (v).end()

int main()
{
  ll H, W; cin >> H >> W;

  if (H%3==0 || W%3==0) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = min(H, W);
  for (int i = 1; i < H; ++i) {
    ll sa = i*W, sb = (H-i)*(W/2), sc = (H-i)*W-sb;
    ans = min(ans, max({sa, sb, sc})-min({sa, sb, sc}));
  }

  for (int i = 1; i < W; ++i) {
    ll sa = i*H, sb = (W-i)*(H/2), sc = (W-i)*H-sb;
    ans = min(ans, max({sa, sb, sc})-min({sa, sb, sc}));
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int N, M;
    int i, j, x;
    int a[51], b[51], c[51], d[51];

    cin >> N >> M;
    for (i = 1; i <= N; i++ ) cin >> a[i] >> b[i];
    for (i = 1; i <= M; i++ ) cin >> c[i] >> d[i];

    for (i = 1; i <= N; i++ ){
      x = 1;
      for (j = 2; j <= M; j++ )  
        if (abs(c[j] - a[i]) + abs(d[j] - b[i]) < 
            abs(c[x] - a[i]) + abs(d[x] - b[i]))
          x = j;
      cout << x << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,i;
  int s=0;
  scanf("%d %d",&n,&m);
  int a[m];
  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
    s=s+a[i];
  }
  if(s<=n)
    printf("%d\n",n-s);
  else if(s>n)
    printf("-1\n");
  return 0;
}
  


Measured memory_bytes: 1688
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  ll n,q;
  cin>>n>>q;
 
  vector<ll> a(n,n-2);
  vector<ll> b(n,n-2);
 
  ll ans=(n-2)*(n-2);
 
  int ta=n-1,yo=n-1;
 
  while(q--){
    int t,x;
    cin>>t>>x;
    x--;
    if(t==1){
      if(x<ta){
        for(int i=x;i<ta;i++){
          b[i]=yo-1;
        }
        ta=x;
      }
      ans-=b[x];
    }
    if(t==2){
      if(x<yo){
        for(int i=x;i<yo;i++){
          a[i]=ta-1;
        }
        yo=x;
      }
      ans-=a[x];
    }
  }
 
 
  cout << ans << endl;
}

Measured memory_bytes: 6316
N,M,X = map(int, input().split())
books = [[] for _ in range(N)]
for i in range(N):
    books[i] = list(map(int, input().split()))
Inf = int(1e20)
ans = Inf
for i in range(2**N):
    a = [0 for _ in range(M+1)]
    for j in range(N):
        if (i & (1 << j)):
            a = [x+y for (x,y) in zip(a,books[j])]
    ok = True
    for k in range(M):
        if a[k+1] < X:
            ok = False
    if not ok:
        continue
    ans = min(ans, a[0])
if ans == Inf:
    ans = -1
print(ans)


Measured memory_bytes: 9264
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

int main() {

    int N;
    cin >> N;

    vector<int> l(N);
    for (int i = 0; i < N; ++i) {
        cin >> l[i];
    }

    int max = *max_element(l.begin(), l.end());
    int sum = accumulate(l.begin(), l.end(), 0);

    if (max < sum - max) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;5
double dp[505][505];
int n;
double p[505];
double q[505];
double psum[505];
double qsum[505];

double search(int l, int r) {
    if(dp[l][r] != 0) return dp[l][r];
    if(l == r) {
        return dp[l][r] = 0;
    }
    dp[l][r] = 1e9;
    double total = qsum[r] - qsum[l-1] + psum[r] - psum[l];
    for(int x = l + 1; x <= r; x++) {
        double left = qsum[x-1] - qsum[l-1] + psum[x-1] - psum[l];
        double right = total - left - p[x];
        double now = (search(l, x - 1) + 1) * (left / total) + (search(x, r) + 1) * (right / total);
        dp[l][r] = min(dp[l][r], now);
    }
    return dp[l][r];
}

int main() {
    cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 2; i <= n + 1; i++) cin >> p[i];
    for(int i = 1; i <= n + 1; i++) cin >> q[i];
    for(int i = 1; i <= n + 1; i++) psum[i] = psum[i-1] + p[i];
    for(int i = i; i <= n + 1; i++) qsum[i] = qsum[i-1] + q[i];
    cout << 1.0 + search(1, n+1) << endl;
    return 0;
}



Measured memory_bytes: 5336
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

void c_back_and_forth(void) {
	int sx, sy, tx, ty;

	int dx, dy;

	cin >> sx >> sy >> tx >> ty;

	//
	dx = tx - sx;
	dy = ty - sy;
	// 1回目 往路
	for (int i = 0; i < abs(dy); i++) {
		if (dy < 0) cout << "D";
		else        cout << "U";
	}
	for (int i = 0; i < abs(dx); i++) {
		if (dx < 0) cout << "L";
		else        cout << "R";
	}
	
	// 1回目復路
	dx = sx - tx;
	dy = sy - ty;
	for (int i = 0; i < abs(dy); i++) {
		if (dy < 0) cout << "D";
		else        cout << "U";
	}
	for (int i = 0; i < abs(dx); i++) {
		if (dx < 0) cout << "L";
		else        cout << "R";
	}

	// 2回目往路
	dx = tx - sx;
	if (dx > 0) {
		dx = tx - (sx - 1);
		cout << "L";
	}
	else {
		dx = tx - (sx + 1);
		cout << "R";
	}
	dy = ty - sy;
	if (dy > 0) {
		dy += 1;
	}
	else {
		dy -= 1;
	}
	for (int i = 0; i < abs(dy); i++) {
		if (dy > 0) cout << "U";
		else        cout << "D";
	}
	for (int i = 0; i < abs(dx); i++) {
		if (dx > 0) cout << "R";
		else        cout << "L";
	}
	if (dy > 0) cout << "D";
	else        cout << "U";

	dx = sx - tx;
	if (dx < 0) {
		dx -= 1;
		cout << "R";
	}
	else {
		dx += 1;
		cout << "L";
	}
	dy = sy - ty;
	if (dy < 0) {
		dy -= 1;
	}
	else {
		dy += 1;
	}
	for (int i = 0; i < abs(dy); i++) {
		if (dy > 0) cout << "U";
		else        cout << "D";
	}
	for (int i = 0; i < abs(dx); i++) {
		if (dx > 0) cout << "R";
		else        cout << "L";
	}

	if (dy < 0) cout << "U";
	else        cout << "D";
}
int main()
{
    c_back_and_forth();

    return 0;
}


Measured memory_bytes: 3636
package main

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

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

func nextInt() int {
	i, e := strconv.Atoi(nextString())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInt64() int64 {
	i, e := strconv.ParseInt(nextString(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

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

func putInt(i int) {
	wr.WriteString(strconv.Itoa(i))
}

func putInt64(i int64) {
	wr.WriteString(strconv.FormatInt(i, 10))
}

func putString(s string) {
	wr.WriteString(s)
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	sc.Buffer(make([]byte, 0), 1000000009)
	sc.Split(bufio.ScanWords)

	var l, r int

	l = nextInt()
	r = nextInt()

	if r > l+2019 {
		r = l + 2019
	}

	var ans int = 2200

	for i := l; i < r; i++ {
		for j := i + 1; j <= r; j++ {
			ans = min(ans, (i*j)%2019)
		}
	}

	putInt(ans)
	putString("\n")

	wr.Flush()
}

Measured memory_bytes: 640