akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
#define pint(x) printf("%d",x)
#define ps printf(" "); 
#define plint(x) printf("%lld",x)
//#define sort(a,n) qsort(a,n,sizeof(int),cmpfunc)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bg begin()
#define ed end()
#define Set(a, s) memset(a, s, sizeof (a))
#define mod 1000000007
#define tmod(k) if ((k) >= mod) k %= mod;
#define endl '\n'
#define nl printf("\n");
#define fors(i,n) for(int i=0; i<n; i++)
#define fore(i,n) for(int i=n-1; i>=0; i--)
#define forv(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef pair<int,int> pii;
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
void ASCII_Chart(){int i,j,k;printf("ASCII Chart:(30-129)\n");forv(i,30,50){fors(j,5){k=i+j*20;printf("%3d---> '%c'   ",k,k);}printf("\n");}}
const int INF = 0x3f3f3f3f;
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}

//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
class node{
public:
	int id;
	int prio;
	int prd;
};

class compare{
public:
	bool operator()(node &n1, node &n2){
		if(n1.prio>n2.prio)//ascending
			return true;
		else if(n1.prio==n2.prio){
			return n1.id>n2.id;
		}
		return false;
	}
};
//priority_queue<node, vector<node>, compare> pq;

int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
    /*#ifdef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #else
    // online submission
    #endif*/
st str;
cin>>str;
    fors(i,str.length()){
        if(str[i]=='9') {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  int n, k;
  while(cin>>n>>k){
    int tmp=1;
    for(int i=0; i<n; ++i){
    if(tmp*2 < tmp+k){
      tmp*=2;
    }
    else{
      tmp+=k;
    }
    }
    cout<<tmp<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int mod = 1e9 + 7,N = 2e5 + 10;
typedef long long LL;
int qmi(int a,int b) {
    int res = 1 % mod;
    while(b) {
        if(b & 1) res = (LL)res * a % mod;
        a = (LL)a * a % mod;
        b >>= 1;
    }
    return res;
}
void addmod(int &x,int y) {
    x += y;
    if(x >= mod) x -= mod;
    if(x < 0) x += mod;
}
int main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,a,b,ans,s = 1;
    cin >> n >> a >> b;
    ans = qmi(2,n);
    addmod(ans, -1);
    for(int i = 1;i <= b; ++i) {
        s = (LL)s * (n - i + 1) % mod;
        s = (LL)s * qmi(i,mod - 2) % mod;
        if(i == a) addmod(ans,-s);
        if(i == b) addmod(ans,-s);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

    int a_xor = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a_xor ^= a;
    }

    cout << (a_xor == 0 ? "Yes" : "No") << endl;
}


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

int main() {
  int n, a, i;
  cin >> n;
  vector<int> buka(n+1);
  for(i = 0; i < n - 1; i++){
    cin >> a;
    buka.at(a)++;
  }
  for(i = 1; i <= n; i++){
    cout << buka.at(i) << endl;
  }
}

Measured memory_bytes: 4000
A,B,K = map(int,input().split())

countK = 0
while(countK<K):
    if countK%2 == 0:
        if A%2 == 1:
            A -= 1
            A = A//2
            B = B + A
        else:
            A = A//2
            B = B + A
    else:
        if B%2 == 1:
            B -= 1
            B = B//2
            A = A + B
        else:
            B = B//2
            A = A + B
    countK += 1
print("{} {}".format(A,B))


Measured memory_bytes: 3060
N,M = map(int ,input().split())
 
used = [False]*N
tolist = [[] for i in range(N)]
 
for i in range(M):
    x,y,z = map(int,input().split())
    x -= 1; y -= 1
    tolist[x].append(y)
    tolist[y].append(x)

cnt = 1 # to N
conti = 0
q = [0]
used[0] = True

i = 0

while q != [] or cnt < N:
    if q == []:
        conti += 1
        found = False
        while i < N:
            if not used[i]:
                found = True
                used[i] = True
                q = [i]
                cnt += 1
                break
            i += 1
    v = q.pop(0)
    for w in tolist[v]:
        if not used[w]:
            used[w] = True
            q.append(w)
            cnt += 1
print(conti+1)

Measured memory_bytes: 23644
#include<stdio.h>
int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int k;
	scanf("%d", &k);
	int cnt = 0;
	while (a >= b)
	{
		cnt++;
		b *= 2;
	}
	while (b >= c)
	{
		cnt++;
		c *= 2;
	}
	if (cnt <= k)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

typedef long long int ll;

int main() {
    optimizar_io
 	int n;

 	cin >> n;
 	ll ans = 0;
 	for (ll x = 1; x <= n; x++) {
 		ll y = n / x;
 		ans += (y * (y + 1) / 2) * x;
 	}
 	cout << ans << "\n";
 	return 0;
}

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

int main() {
  int h,w; cin >> h >> w;
  vector<string> ws(h); 

  rep(i, h) {
    cin >> ws[i];
  }

  int count;
  vector<int> col(w);
  rep(i,w){
    int sum = 0;
    rep(j, h){
      if (ws[j][i] == '.')
        sum++;
    }
    if (sum == h)
      col[i] = 1;
    else 
      col[i] = 0;
  }

  rep(i, h){
    if(ws[i] != string(w, '.')) {
      rep(j, w) {
        if (col[j] == 0)
          cout << ws[i][j];
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

ll MOD = 1000000007;
ll lcm(ll a, ll b) { return (a / __gcd(a, b) * b); }

int main() {
  //
  ll n;
  cin >> n;
  set<int> primes;
  primes.insert(2);
  for (int i = 3; i <= 1000; i++) {
    int j = i;
    for (auto& p : primes) {
      while (j % p == 0) {
        j /= p;
      }
    }
    if (j > 1) primes.insert(j);
  }
  map<int, ll> m;
  for (int i = 2; i <= n; i++) {
    int j = i;
    for (auto& p : primes) {
      while (j % p == 0) {
        if (m.find(p) == m.end()) {
          m[p] = 1LL;
        } else {
          m[p]++;
        }
        j /= p;
      }
    }
  }
  ll ans = 1;
  for (auto& x : m) {
    // cout << x.first << "," << x.second << endl;
    ans = ans * (x.second + 1) % MOD;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int x, y;
    cin >> x >> y;
    vector<int> a = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
    cout << (a[x - 1] == a[y - 1] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> H;
  vector<int> W;
  int tmpH, tmpW, cnt;
  REP(i, 1e6){
    cin >> tmpH >> tmpW;
    if(tmpH == 0 && tmpW == 0){
      cnt = i;
      break;
    }
    H.push_back(tmpH);
    W.push_back(tmpW);
  }
  REP(i, cnt){
    REP(j, H.at(i)){
      REP(k, W.at(i)){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}



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

int main(){
  string input;
  stack<int> s;
  while(cin >> input){
    int n;
    int a, b;
    if(input == "+"){
      a = s.top(); s.pop();
      b = s.top(); s.pop();
      n = a + b;
    }else if(input == "*"){
      a = s.top(); s.pop();
      b = s.top(); s.pop();
      n = a * b;
    }else if(input == "-"){
      a = s.top(); s.pop();
      b = s.top(); s.pop();
      n = b - a;
    }else{
      int ans = 0;
      for(int i = 0; input[i] != '\0'; i++){
        ans = ans*10 + input[i] - '0';
      }
      n = ans;
    }
    s.push(n);
  }
  cout << s.top() << endl;
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
const int N=805;
int n,m,k;
char s[N][N];
int d[N][N],qx[N*N],qy[N*N];
int dx[4]={ 0, 0,-1, 1};
int dy[4]={-1, 1, 0, 0};
bool check(int x,int y){
	return 1<=x&&x<=n&&1<=y&&y<=m&&s[x][y]!='#';
}
int main(){
	cin >> n >> m >> k;
	for (int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	memset(d,0,sizeof d);
	int sx,sy;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (s[i][j]=='S')
				sx=i,sy=j;
	int head=0,tail=0;
	tail++;
	qx[tail]=sx,qy[tail]=sy;
	d[sx][sy]=1;
	while (head<tail){
		head++;
		int x=qx[head],y=qy[head];
		if (d[x][y]==k+1)
			continue;
		for (int i=0;i<4;i++){
			int nx=x+dx[i],ny=y+dy[i];
			if (!check(nx,ny)||d[nx][ny])
				continue;
			d[nx][ny]=d[x][y]+1;
			tail++;
			qx[tail]=nx,qy[tail]=ny;
		}
	}
	int ans=23333;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (s[i][j]!='#'&&d[i][j]){
				if (i==1||j==1||i==n||j==m)
					ans=1;
				else {
					ans=min(ans,(i-1+k-1)/k+1);
					ans=min(ans,(j-1+k-1)/k+1);
					ans=min(ans,(n-i+k-1)/k+1);
					ans=min(ans,(m-j+k-1)/k+1);
				}
			}
	cout << ans;
	return 0;
}

Measured memory_bytes: 8448
x = list(map(int, input().split()))
N,T=x[0],x[1]
t=list(map(int, input().split()))
oyu=0

for i in range(1,N):
    if(t[i]-t[i-1]<T):
        oyu += t[i]-t[i-1]
    else:
        oyu += T
        

oyu += T
print(oyu)
quit()

Measured memory_bytes: 25200
n = int(input())
a = list(map(int, input().split()))
now = 1

if n == 0 and a[0] == 1:
    print(1)
    exit()
if a[0] != 0:
    print(-1)
    exit()
dnl = [0] * (n+1)
for d,v in enumerate(a[:-1]):
    if now < v:
        print(-1)
        exit()
    dnl[d] = now - v
    now = (now - v) * 2
if now < a[-1]:
    print(-1)
    exit()
elif now//2 <= a[-1] <= now:
    print(sum(dnl) + sum(a))
    exit()
else:
    for i in range(n,0,-1):
        if dnl[i] + a[i] < dnl[i-1]:
            dnl[i-1] = dnl[i] + a[i] 
        else:
            break
    print(sum(dnl) + sum(a))

Measured memory_bytes: 700636
#include <cstdio>
#include <cstdlib>

int path[5][3];

bool vis[5];
void DFS(register int o)
{ 
	vis[o]=true;
	bool fal=false;
	for(register int i=1;i<=path[o][0];i++)
		if(!vis[path[o][i]])
			DFS(path[o][i]),fal=true;
	if(!fal)
	{
		for(register int i=1;i<=4;i++)
		if(!vis[i])
		{
			printf("NO\n");
			exit(0);
		}
		printf("YES\n");
		exit(0);
	}
}

int main()
{
	for(register int i=1;i<=3;i++)
	{
		int a,b;scanf("%d%d",&a,&b);
		path[a][++path[a][0]]=b,path[b][++path[b][0]]=a;
	}
	DFS(1);
	return 0; 
} 

Measured memory_bytes: 128
N = int(input())
li1 = [input() for _ in range(N)]
M = int(input())
li2 = [input() for _ in range(M)]
ans = 0
for i in set(li1):
    tmp = li1.count(i) - li2.count(i)
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int main() {
  int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  a--;b--;c--;d--;
  string s;
  cin >> s;
  int type=-1;
  if(a<b&&c<d) type=1;
  else if(a<b&&d<c) type=2;
  else type =3;
  bool can = true;
  if(type==1){
    for(int i=a+1;i<d-1;i++){
        if(s[i]=='#'&&s[i+1]=='#')
          can = false;
    }
  }
  else if(type==2){
    for(int i=a+1;i<c-1;i++){
        if(s[i]=='#'&&s[i+1]=='#')
          can = false;
    }
    bool can2=false;
    for(int i=b-1;i<=d-1;i++){
      if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.')
          can2 = true;
    }
    if(can2==false) can = false; 
  }
  else if(type==3){
    for(int i=a+1;i<c-1;i++){
        if(s[i]=='#'&&s[i+1]=='#')
          can = false;
    }
    for(int i=b+1;i<d-1;i++){
        if(s[i]=='#'&&s[i+1]=='#')
          can = false;
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char c[][] = new char[H][W];
		for (int i=0;i<H;i++) {
			char ch[] = sc.next().toCharArray();
			for (int j=0;j<W;j++) {
				c[i][j] = ch[j];
			}
		}
		int a[][]= new int[H][W];
		int h = 0;
		int w = 0;
		a[h][w]=1;
		while (h<=H-1&&w<=W-1) {
			if (w<W-1) {
				if (c[h][w+1]=='#') {
					w++;
					a[h][w]=1;
				} else if (h<H-1) {
					if (c[h+1][w]=='#') {
						h++;
						a[h][w]=1;
					} else {
						System.out.println("Impossible");
						return ;
					}
				} else {
					System.out.println("Impossible");
					return ;
				}
			} else {
				if (h<H-1) {
					if (c[h+1][w]=='#') {
						h++;
						a[h][w]=1;
					} else {
						System.out.println("Impossible");
						return ;
					}
				} else {
					h++;
				}
			}
		}
		for (int i=0;i<H;i++) {
			for (int j=0;j<W;j++) {
				if (a[i][j]==0&&c[i][j]=='#') {
					System.out.println("Impossible");
					return ;
				}
			}
		}
		System.out.println("Possible");
	}
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

int H, W;
vs s;

void solve()
{
    cin >> H >> W;
    s.resize(H); REP(i, H) cin >> s[i];

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

    REP(i, H)
    {
        REP(j, W)
        {
            if(s[i][j] == '#')
            {
                bool ok = false;
                REP(k, 4)
                {
                    int y = i + dy[k];
                    int x = j + dx[k];
                    if(0 <= y && y < H && 0 <= x && x < W && s[y][x] == '#') ok = true;
                }
                if(!ok)
                {
                    cout << "No" << endl;
                    return;
                }
            }
        }
    }
    cout << "Yes" << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9) {
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
}

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

ll mod = 1e9+7;

ll modpower(ll a, ll r){ //a^r
    ll x = 1;
    a %= mod;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a){
    return modpower(a, mod-2);
}

vector<ll> fact;
vector<ll> invfact;

void set_fact(int n){
    fact.resize(n+1, 1);
    invfact.resize(n+1, 1);
    for (int i = 2; i <= n; i++) {
        fact[i] = fact[i-1] * i % mod;
    }
    invfact[n] = modinv(fact[n]);
    for (int i = n-1; i >= 2; i--) {
        invfact[i] = invfact[i+1] * (i+1) % mod;
    }
    return;
}

ll comb(int n, int k) {
    if (k > n || k < 0) return 0;
    if (k == n || k == 0) return 1;
    return fact[n] * invfact[n-k] % mod * invfact[k] % mod;
}

int N;
vector<vector<int>> edge;
vector<int> par, size;

void dfs(int now, int p) {
    par[now] = p;
    int s = 1;
    for (int nxt : edge[now]) {
        if (nxt == p) continue;
        dfs(nxt, now);
        s += size[nxt];
    }
    size[now] = s;
    return;
}

vector<ll> c;
void dfs2(int now) {
    ll cc = 1;
    ll csum = 0;
    ll den = 1;
    for (int nxt : edge[now]) {
        if (nxt == par[now]) continue;
        csum += size[nxt];
        den = den * fact[size[nxt]] % mod;
        dfs2(nxt);
        cc = cc * c[nxt] % mod;
    }
    c[now] = cc * fact[csum] % mod * modinv(den) % mod;
    return;
}

vector<ll> p;
void dfs3(int now) {
    if (now == 1) p[now] = 1;
    else {
        ll pp = c[par[now]];
        pp = pp *  modinv(comb(size[par[now]]-1, size[now])) % mod * modinv(c[now]) % mod;
        pp = pp * p[par[now]] % mod * comb(N-size[now]-1, size[par[now]]-size[now]-1) % mod;
        p[now] = pp;
    }
    for (int nxt : edge[now]) {
        if (nxt == par[now]) continue;
        dfs3(nxt);
    }
    return;
}



int main() {
    cin >> N;
    edge.resize(N+1);
    par = vector<int>(N+1, 0);
    size = vector<int>(N+1, 0);
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    set_fact(N+2);
    dfs(1, -1);
    c.resize(N+1, 0);
    c[0] = 1;
    dfs2(1);
    p.resize(N+1, 0);
    p[0] = 1;
    dfs3(1);
    
    for (int i = 1; i <= N; i++) {
        ll ans = p[i];
        ans = ans * fact[N-1] % mod * invfact[N-size[i]] % mod;
        for (int nxt : edge[i]) {
            if (nxt == par[i]) continue;
            ans = ans * c[nxt] % mod * invfact[size[nxt]] % mod;
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 21748
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
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; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;



void solve() {
	int ans = 0;
	int L, R, d; cin >> L >> R >> d;
	FOR(i, L, R + 1) {
		if (i%d == 0)ans++;
	}
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 3676
#include <stdio.h>
#include <iostream>
#include <vector>

int main()
{
	int n, m;
	int i;
	int num;

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

	std::vector<int> v;
	std::vector<int> w;

	for (i = 0; i < m; i++) {
		std::cin >> num;
		v.push_back(num);
	}
	sort(v.begin(), v.end());

	for (i = 0; i < m - 1; i++) {
		w.push_back(v[i+1] - v[i]);
	}
	sort(w.begin(), w.end());

	int sum = 0;
	for (i = 0; i < m - n; i++)
		sum += w[i];

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

	return 0;
}

Measured memory_bytes: 1400
S = str(input())

a, b = 0, 0

#YYMM
if 1 <= int(S[2:]) and int(S[2:]) <= 12:
  a = 1
#MMYY
if 1 <= int(S[:2]) and int(S[:2]) <= 12:
  b = 1
  
if a == 1 and b == 1:
  print("AMBIGUOUS")
elif a == 1 and b == 0:
  print("YYMM")
elif a == 0 and b == 1:
  print("MMYY")
else:
  print("NA")


Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;
 
fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main(){
    let n = read::<usize>();
    let mut ans: f64 = 0.0;

    for _x in 0..n {
        let a = read::<f64>();
        ans += 1.0/a;
    }

    println!("{}",1.0/ans);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        Set<Integer> set = new HashSet<Integer>();
        int result = 0;
        set.add(s);
        for (int i = 2; i < 1000000; i++) {
            s = s % 2 == 0 ? (s / 2) : (3 * s + 1);
            if (set.contains(s)) {
                result = i;
                break;
            } else {
                set.add(s);
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23124
#include <iostream>
using namespace std;
int main()
{
	int r,D,x;
	cin>>r>>D>>x;
	int a[15];
	a[0]=x;
	for(int i=1;i<=10;i++)
	{
		a[i]=a[i-1]*r-D;
		cout<<a[i]<<endl;
	}
	return 0;
}

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

using namespace std;

int
main ()
{
  string s;
  cin >> s;

  int count = 0;
  for (int i = 0; i < 3; i++)
    {
      if (s[i] == '1')
	{
	  count++;
	}
    }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N,X;cin>>N>>X;
  std::vector<int> v(N),w(N+1);
  for(int i=0;i<N;i++)cin>>v[i];
  w[0]=0;for(int i=0;i<N;i++)w[i+1]=w[i]+v[i];
  int fans=LINF;
  for(int i=1;i<=N;i++){
    int ans=X*(N+i);
    ans+=(w[N]-w[N-i])*5;
    for(int j=i;j<N;j+=i){
      ans+=(w[N-j]-w[max(N-j-i,0LL)])*(2*j/i+3);
      if(ans>LINF||ans<0){ans=LINF;break;}
    }
    fans=min(ans,fans);
  }
  cout<<fans<<endl;
}


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

int main(){
  long long n;
  cin >> n;
  long long a;
  int cntm = 0;
  long long ans=0;
  long long minnum = 1000000000;

  for (long long i = 0; i < n; i++)
  {
    cin >> a;
    ans+=abs(a);
    minnum = min(minnum,abs(a));
    if(a<0) cntm++;
  }

  if(cntm%2 == 1){
    ans -= minnum*2;
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
    int values[3];
    scanf("%d %d %d", values, values + 1, values + 2);
    for (int *until = values + 2; until != values; --until)
    {
        for (int *elm = values; elm != until; ++elm)
        {
            if (*elm > *(elm + 1))
            {
                const int v = *elm;
                *elm = *(elm + 1);
                *(elm + 1) = v;
            }
        }
    }
    printf("%d %d %d\n", values[0], values[1], values[2]);
    return 0;
}



Measured memory_bytes: 2088
N, K =map(int, input().split())
total = 0
for i in range(1, N + 1):
    if i >= K:
        total += 1
    else :
        coin = 0
        while i < K:
            coin += 1
            i = i * 2
        total += 2 ** (-coin)
print(total / N)


Measured memory_bytes: 2940
fun main(args: Array<String>) {
    val (H, W) = listOfLong()
    println(if (H == 1L || W == 1L) 1 else (H * W + 1) / 2)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 37612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<n+1;i++)
typedef vector<int> vec;

int main(){
  long n,k,ans=1e+18; cin>>n>>k;
  n=n%k;
  ans=n;
  rep(i,10000000){ans=min(ans,abs(n-k)); n=abs(n-k);}
  cout<<ans<<endl;
}

Measured memory_bytes: 3580
#include<cstdio>
bool f[100001];
int  c[100002];
int N, L, R;
int main()
{
    for(int i = 2; i <= 100000; ++i) 
        if(!f[i])
            for(int j = i + i; j <= 100000; j += i)
                f[j] = true;
    
    for(int i = 3; i <= 100000; i += 2)
        if(!f[i] && !f[(i+1)/2]) c[i]++;
    
    for(int i = 3; i <= 100000; ++i) c[i] += c[i-1];
    scanf("%d", &N);
    while(N--) {
        scanf("%d %d", &L,&R);
        printf("%d\n", c[R] - c[L-1]);
    }

    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX;
using ll = long long;

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

    int N;
    cin >> N;
    vector<char> vec(N);
    rep (i, N)
        cin >> vec[i];

    vector<int> w(N);
    vector<int> e(N);
    int cnt = 0;
    rep (i, N) {
        if (vec[i] == 'W') cnt++;
        w[i] = cnt;
    }
    cnt = 0;
    rep (i, N) {
        if (vec[N - 1 - i] == 'E') cnt++;
        e[N - 1 - i] = cnt;
    }
    int min = INF;
    rep (i, N) {
        int tmp = 0;
        if (i == 0)
            tmp = e[1];
        else if (i == N - 1)
            tmp = w[N - 2];
        else
            tmp = e[i + 1] + w[i - 1];

        if (tmp < min) min = tmp;
    }

    print(min);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 2944
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let k: usize = read();

    let mut hs = Vec::new();
    for _ in 0..n {
        hs.push(read::<usize>());
    }

    // 必殺技を全部使用する

    if hs.len() < k {
        println!("0");
        return;
    }
    hs.sort_by(|a, b| b.cmp(a));

    let hs = &hs[(k as usize)..];

    let result: usize = hs.iter().sum();

    println!("{}", result);
}

/// Example
/// ```
///
///  let n: i32 = read();
///
///  let mut xs = Vec::new();
///  for _ in 0..n {
///      xs.push(read::<i32>() + 1000);
///  }
/// ```
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn hoge() {
        assert_eq!(run(20, 15), 0);
        assert_eq!(run(20, 30), 0);
        assert_eq!(run(12, 4), 4);
    }
}


Measured memory_bytes: 6396
#include<stdio.h>
#include<math.h>

//judge prime number
int prime(int);

int main(){
  int num, data, i, cnt=0;

  //input data numbers
  scanf("%d",&num);

  for(i=0;i<num;i++){
    //input data
    scanf("%d",&data);


    //if data is prime number cnt++
    cnt+=prime(data);
  }

  //output result
  printf("%d\n",cnt);
  
  return 0;
}


//judge prime number
//if data is prime number return 1
//else return 0
int prime(int data){
  int i;
  
  if(data==2) return 1; //2 is prime number
  if(data<2 || data%2==0) return 0; // <2 or %2==0 is not prime number

  for(i=3;i<=sqrt(data);i+=2){
    if(data%i==0) return 0; // %i==0 is not prime number
  }

  return 1; 
}



Measured memory_bytes: 2048
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int as[30];
int bs[30];
int cs[30];

int main(void) {
  int n;
  cin >> n;
  int res = 0;
  REP(i, n) {
    cin >> as[i];
  }
  REP(i, n) {
    cin >> bs[i];
    res += bs[i];
  }
  REP(i, n-1) {
    cin >> cs[i];
  }
  REP(i, n-1) {
    if(as[i]+1 == as[i+1]) {
      res += cs[as[i]-1];
    }
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int blocks[][] = new int[10][10];
		int blank=0,max=0;

		while((str=br.readLine()) != null){
			String strArray[] = str.split(",");
			int x = Integer.parseInt(strArray[0]);
			int y = Integer.parseInt(strArray[1]);
			int size = Integer.parseInt(strArray[2]);

			drop(blocks, x, y, size);

		}

		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(blocks[i][j]==0){
					blank++;
				}else if(blocks[i][j]>max){
					max = blocks[i][j];
				}
			}
		}

		System.out.println(blank);
		System.out.println(max);

	}

	static void drop(int blocks[][],int x, int y, int size){
		if(size == 1)//小の滴
			min_drop(blocks, x, y);
		if(size == 2)
			mid_drop(blocks, x, y);
		if(size == 3)
			lag_drop(blocks, x, y);
	}

	static void min_drop(int blocks[][], int x, int y){
		blocks[x][y]++;
		if(x-1>-1)
			blocks[x-1][y]++;
		if(x+1<10)
			blocks[x+1][y]++;
		if(y-1>-1)
			blocks[x][y-1]++;
		if(y+1<10)
			blocks[x][y+1]++;
	}

	static void mid_drop(int blocks[][], int x, int y){
		min_drop(blocks, x, y);
		if(-1<x-1 && -1<y-1)
			blocks[x-1][y-1]++;
		if(x+1<10 && -1<y-1)
			blocks[x+1][y-1]++;
		if(-1<x-1 && y+1<10)
			blocks[x-1][y+1]++;
		if(x+1<10 && y+1<10)
			blocks[x+1][y+1]++;
	}

	static void lag_drop(int blocks[][], int x, int y){
		mid_drop(blocks, x, y);
		if(-1<y-2)
			blocks[x][y-2]++;
		if(y+2<10)
			blocks[x][y+2]++;
		if(-1<x-2)
			blocks[x-2][y]++;
		if(x+2<10)
			blocks[x+2][y]++;
	}
}

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;

template< typename T >
struct PrioritySumStructure {
  static const bool INCREASE = false;
  static const bool DECREASE = true;

  bool order;
  int k, sz;
  T sum;
  set< pair< T, int > > add, pend;
  map< int, T > adding, pending;

  PrioritySumStructure(int k, bool order = INCREASE) : k(k), sum(0), sz(0), order(order) {}

  void Sweep() {
    while(sz < k && !pend.empty()) {
      auto p = order ? --pend.end() : pend.begin();
      sum += p->first;
      ++sz;
      add.emplace(*p);
      adding.emplace(p->second, p->first);
      pending.erase(p->second);
      pend.erase(p);
    }
    while(sz > k) {
      auto p = order ? add.begin() : --add.end();
      sum -= p->first;
      --sz;
      pend.emplace(*p);
      pending.emplace(p->second, p->first);
      adding.erase(p->second);
      add.erase(p);
    }
  }

  T getSum() {
    if(sz < k) throw ("get Sum Exception");
    return (sum);
  }

  void addElement(int k, T x) {
    if(adding.count(k) || pending.count(k)) {
      throw ("Add Element Exception");
    }
    ++sz;
    add.emplace(x, k);
    adding[k] = x;
    sum += x;
    Sweep();
  }

  void deleteElement(int k) {
    if(pending.count(k)) {
      pend.erase({pending[k], k});
      pending.erase(k);
    } else if(adding.count(k)) {
      --sz;
      sum -= adding[k];
      add.erase({adding[k], k});
      adding.erase(k);
      Sweep();
    } else {
      throw ("delete Element Exception");
    }
  }

  void incrementSize() {
    ++k;
    Sweep();
  }

  void decrementSize() {
    if(k == 0) throw ("decrement Size Exception");
    --k;
    Sweep();
  }
};


int main() {
  int N, A[300000];

  cin >> N;
  for(int i = 0; i < 3 * N; i++) {
    cin >> A[i];
  }

  // 前半を最大化
  // 後半を最小化
  // えー(?)
  int64 ret = -INF;
  // えーーーー(???)
  // わからず
  // うく
  // あーわかりましたが
  PrioritySumStructure< int64 > beet(N, true);
  PrioritySumStructure< int64 > ukuku(N, false);
  vector< int64 > dp1(3 * N, -INF);
  for(int i = 0; i < 3 * N; i++) {
    beet.addElement(i, A[i]);
    if(beet.sz >= N) dp1[i] = beet.getSum();
  }
  vector< int64 > dp2(3 * N, INF);
  for(int i = 3 * N - 1; i >= 0; i--) {
    ukuku.addElement(i, A[i]);
    if(ukuku.sz >= N) dp2[i] = ukuku.getSum();
  }
  for(int i = 0; i < 3 * N - 1; i++) {
    ret = max(ret, dp1[i] - dp2[i + 1]);
  }
  cout << ret << endl;
}




Measured memory_bytes: 81152
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007ll
#define inf 9999999999999999ll

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vf a(n,0);
    for(ll i=0;i<n;i++)
    {
        ll target=k;
        ll curr=(i+1);
        if(curr>=target)
        {
            a[i]=1;
            continue;
        }
        ll num_head=ceil(log2((lf)target/(lf)curr));
        if(num_head<=50)
            a[i]=1/powl(2,num_head);
    }
    lf ans=0;
    for(ll i=0;i<n;i++)
    {
        ans+=a[i];
    }
    ans/=n;
    printf("%.15Lf\n",ans);
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

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

int main() {
    int h,w,n;cin >> h >> w >> n;
    int Max = max(h,w);
    cout << (n + (Max-1))/Max << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def floor_sum(n, m, a, b):
    ans = 0
    while True:
        if a >= m:
            ans += (n-1)*n*(a//m)//2
            a %= m
        if b >= m:
            ans += n*(b//m)
            b %= m

        yMax = (a*n+b) // m
        xMax = yMax*m - b
        if yMax == 0:
            break
        ans += (n-(xMax+a-1)//a) * yMax
        n, m, a, b = yMax, a, m, (-xMax)%a

    return ans


T = int(input())

anss = []
for _ in range(T):
    N, M, A, B = map(int, input().split())
    ans = floor_sum(N, M, A, B)
    anss.append(ans)

print('\n'.join(map(str, anss)))


Measured memory_bytes: 19720
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int n; cin >> n;
	if(n==7 or n==5 or n==3) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll k,a,b;
int main()
{
	cin>>k>>a>>b;
		ll fans=k+1;
		k++;
		ll ans=a;
		k-=a;
		// 100 2 6
		// 101
		// 99 2 
		// 98 0 1
		// 2 6 0
		// 96 4 1
		// 95 2 2
		// 94 0 3
		// 93 6 2
		// 92 12 1
		// 91 18 0
		ll c=0ll;
		if(k&1)
		{
			ans++;
			k--;
		}
		// 8 3 4
		// 5 3 4
		// 4 4 0
		// 
		// db(k);
		ans+=(k/2)*(b-a);
		ans=max(ans,fans);
		cout<<ans<<endl;
	
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int p[N];
  int p_max=0, total=0;

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

  for(int i=0;i<K;i++) total += p[i];
  if(p_max<total) p_max = total;

  for(int i=K;i<N;i++){
    total = total + p[i] - p[i-K];
    if(p_max<total) p_max = total;
  }

  printf("%.10f\n",p_max/2.0);

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int maxn = 5e5 + 7;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

int main(){
    int n;
    scanf("%d",&n);
    int a = 0,b = 0,c = 0,d = 0;
    while(n--){
    	string s;
    	cin >> s;
    	if(s == "AC") a++;
    	if(s == "WA") b++;
    	if(s == "TLE") c++;
    	if(s == "RE") d++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,b,c,d);
}

Measured memory_bytes: 3784
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	m := make(map[int]int)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)

		m[tmp-1]++
		m[tmp]++
		m[tmp+1]++
	}

	ans := 0
	for _, x := range m {
		ans = max(ans, x)
	}

	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 8064
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    s=readline().strip()

    cnt=1
    for i in range(len(s)):
        if i==0:
            now=s[i]
        else:
            if now!=s[i]:
                cnt+=1
                now=s[i]

    print(cnt-1)

if __name__=="__main__":
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
void update(int& n, int m){
  n = max(n, m);
}

int main(){
  int C, N, M, X;
  while(cin>>C>>N>>M>>X && C){
    int c_s[101] = {}, e_s[101] = {};
    int c[101] = {}, e[101] = {};
    char tmp[256];
    REP(i, N){
      scanf("%s %d %d", tmp, &c_s[i], &e_s[i]);
    }
    REP(i, M){
      scanf("%s %d %d", tmp, &c[i], &e[i]);
    }
    int dp[2][101][1001] = {}; // i use money
    memset(dp, -1, sizeof(dp));
    dp[0][0][0] = 0;
    for(int i = 0; i < M; i++){
      for(int use = 0; use <= i; use++){
        for(int cost = 0; cost <= C; cost++){
          if(cost + c[i] <= C && dp[i % 2][use][cost] != -1) update(dp[(i + 1) % 2][use + 1][cost + c[i]], dp[i % 2][use][cost] + e[i]);
          update(dp[(i + 1) % 2][use][cost], dp[i % 2][use][cost]);
        }
      }
    }
    for(int use = 1; use <= M; use++){
      for(int cost = 1; cost <= C; cost++){
        update(dp[M%2][use][cost], dp[M%2][use][cost - 1]);
      }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
      for(int j = i + 1; j <= N; j++){
        int rest = C - (c_s[i] + c_s[j]);
        if(rest <= 0) continue;
        int effect_c = e_s[i] + e_s[j];
        int effect = 0;
        for(int use = X; use <= M; use++){
          update(effect, dp[M%2][use][rest]);
        }
        ans = max(ans, effect_c + effect);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2044
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#define F first
#define S second
using namespace std;
int n, t, h, mx, c2, num, a[100005];
map<int, int> c;
pair<int, int> b[100005];
bool v[100005];
int main()
{
    int i;
    cin >> n >> t;
    for (i = 0; i < n; i++) {
        scanf ("%d", &a[i]);
        b[i].F = a[i];
        b[i].S = i;
    }
    sort(b, b + n);
    for (i = 0; i < n; i++) {
        c[b[i].F] = i;
    }
    h = n - 1;
    mx = -2e9;
    for (i = 0; i < n; i++) {
        v[c[a[i]]] = true;
        while (h >= 0) {
            if (!v[h]) break;
            h--;
        }
        num = 0;
        if (h >= 0 && mx < b[h].F - a[i]) {
            mx = b[h].F - a[i];
            c2 = 1;
        } else if (h >= 0 && mx == b[h].F - a[i]) {
            c2++;
        }
    }
    cout << c2 << endl;
    return 0;
}


Measured memory_bytes: 6144
#   include <stdio.h>
int main()
{
  int n,m,ans=0;
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n-1;i++)
    ans+=i;
  for(int j=1;j<=m-1;j++)
    ans+=j;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int32 i = (b) - 1; i >= (a); --i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;


inline uint32 popcount(uint32 c) {
	c = (c & 0x55555555) + ((c >> 1) & 0x55555555);
	c = (c & 0x33333333) + ((c >> 2) & 0x33333333);
	c = (c & 0x0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f);
	c = (c & 0x00ff00ff) + ((c >> 8) & 0x00ff00ff);
	c = (c & 0x0000ffff) + ((c >> 16) & 0x0000ffff);
	return c;
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	cin >> n;
	uint32 f[100]={};
	int32 p[100][10] = {};
	uint32 a;
	rep(i, 0, n) {
		rep(j, 0, 10) {
			cin >> a;
			f[i] |= a << j;
		}
	}
	rep(i, 0, n) {
		rep(j, 0, 11)
			cin >> p[i][j];
	}
	int64 ans = -1e18;
	int64 cur;
	rep(i, 1, 1024) {
		cur = 0;
		rep(j, 0, n) {
			cur += p[j][popcount(i&f[j])];
		}

		ans = max(ans, cur);
	}
	printf("%lld", ans);
	return 0;
}

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)2
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 1000005
#define mxnn 2000005
int dp[mxn][3];
int arr[mxn][3];
int32_t main(){
sp;
int n;
cin >>n;
for(int i = 1;i<=n;i++)cin >>arr[i][0]>>arr[i][1]>>arr[i][2];
for(int i = 1;i<=n;i++){
    for(int j = 0;j<3;j++){
        for(int k = 0;k<3;k++){
            if(j == k) continue;
            dp[i][j] = max(dp[i][j],dp[i-1][k]+arr[i][j]);
        }
    }
}
int ans = 0;
for(int i = 0;i<3;i++) ans = max(ans,dp[n][i]);
cout<<ans;
return 0;
}


Measured memory_bytes: 8448