akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
const double EPS=1e-10;
struct point{
	double x,y;
	point(const point&a):x(a.x),y(a.y){}
	point(const double&x=0,const double&y=0):x(x),y(y){}
	point operator+(const point&p)const{return point(x+p.x,y+p.y);}
	point operator-(const point&p)const{return point(x-p.x,y-p.y);}
	point operator*(const double&k)const{return point(x*k,y*k);}
	point operator/(const double&k)const{return point(x/k,y/k);}
	double norm(){return x*x+y*y;}
	double abs(){return sqrt(norm());}
	void operator=(const point&a){
		x=a.x,y=a.y;
	}
	bool operator<(const point&p)const{
		return x!=p.x?x<p.x:y<p.y;
	}
	bool operator==(const point&p)const{
		return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
	}
	friend double dot(const point&a,const point&b){
		return a.x*b.x+a.y*b.y;
	}
	friend double cross(const point&a,const point&b){
		return a.x*b.y-a.y*b.x;
	}
};
typedef point vector;
struct segment{
	point p1,p2;
	segment(const double&a,const double&b,const double&c,const double&d){
		p1.x=a,p1.y=b,p2.x=c,p2.y=d;
	}
	segment(const point&a, const point&b):p1(a),p2(b){}
	point get_vec()const{return point(p2.x-p1.x,p2.y-p1.y);}
	double abs()const{return get_vec().abs();}
};
bool orthogonal(const vector&a,const vector&b){
	return fabs(dot(a,b))<EPS;
}
bool orthogonal(const point&a,const point&b,const point&c,const point&d){
	return fabs(dot(a-b,c-d))<EPS;
}
bool orthogonal(const segment&a,const segment&b){
	return fabs(dot(a.get_vec(),b.get_vec()))<EPS;
}
bool parallel(const vector&a,const vector&b){
	return fabs(cross(a,b))<EPS;
}
bool parallel(const point&a,const point&b,const point&c,const point&d){
	return fabs(cross(a-b,c-d))<EPS;
}
bool parallel(const segment&a,const segment&b){
	return fabs(cross(a.get_vec(),b.get_vec()))<EPS;
}
point project(const segment&s,const point&p){
	vector base=s.get_vec();
	double r=dot(p-s.p1,base)/base.norm();
	return s.p1+base*r;
}
point reflect(const segment&s,const point&p){
	return p+(project(s,p)-p)*2.0;
}
int ccw(const point&a,const point&b,const point&c){
	vector t1=b-a;
	vector t2=c-a;
	if(cross(t1,t2)>EPS) return 1;
	if(cross(t1,t2)<-EPS) return -1;
	if(dot(t1,t2)<-EPS) return -2;
	if(t1.norm()<t2.norm()) return 2;
	return 0;
}
bool intersect(const point&a,const point&b,const point&c,const point&d){
	return ((ccw(a,b,c)*ccw(a,b,d))<=0&&(ccw(c,d,a)*ccw(c,d,b))<=0);
}
bool intersect(const segment&a,const segment&b){
	return intersect(a.p1,a.p2,b.p1,b.p2);
}
point intersect_point(const segment&s1,const segment&s2){
	double d1=fabs(cross(s2.p1-s1.p1,s1.get_vec()));
	double d2=fabs(cross(s2.p2-s1.p1,s1.get_vec()));
	double t=d1/(d1+d2);
	return s2.p1+s2.get_vec()*t;
}
int main(){
	double a,b,c,d;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c>>d;
		segment s1(a,b,c,d);
		cin>>a>>b>>c>>d;
		segment s2(a,b,c,d);
		point t=intersect_point(s1,s2);
		cout<<setprecision(8)<<fixed<<t.x<<' '<<t.y<<endl;
	}
	return 0;
}



Measured memory_bytes: 3288
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define INF 1000000007

long dp[1005][1005];
char a[1005][1005];

int def(int H,int W);

int main(void){
  int H,W,i,j;
  char str[1100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  H=atoi(p);
  p=strtok(NULL," \n");
  W=atoi(p);
  
  for(i=0;i<H;i++){
    fgets(str,sizeof(str),stdin);
    strcpy(a[i],str);
  }
  
  def(H,W);
  
  printf("%ld\n",dp[H-1][W-1]);
  
  return 0;
}

int def(int H,int W){
  int i,j;
  
  dp[0][0]=1;
  
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if(a[i][j]=='.'){
        if(i>0 && j>0){
          dp[i][j]=dp[i-1][j]+dp[i][j-1];
          dp[i][j]%=INF;
        }else if(i==0 && j>0){
          dp[i][j]=dp[i][j-1];
          dp[i][j]%=INF;
        }else if(i>0 && j==0){
          dp[i][j]=dp[i-1][j];
          dp[i][j]%=INF;
        }
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 8960
h,w=map(int,input().split())
paint=[]
paint.append(["." for _ in range(w+2)])
for i in range(h):
    P=["."] +list(input()) +["."]
    paint.append(P)
paint.append(["." for _ in range(w+2)])
ans="Yes"
for i in range(h):
    for j in range(w):
        if paint[i+1][j+1]=="#":
            if not(paint[i][j+1]=="#" or paint[i+1][j]=="#" or paint[i+1][j+2]=="#" or paint[i+2][j+1]=="#"):
                ans="No"
                break
    else:
        continue
    break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
    int n = 0 , c = 0, m;
    while (!isdigit(c)) m = c - 45 ? 1 : -1 , c = getchar();
    while (isdigit(c))  n = n * 10 + c - 48 , c = getchar();
    return m * n;
}
const int N = 1e6 + 1;
char a[60] , b[60];
bool fun(int l , int r){
    int c = 1;
    for(int i = l; i <= r; i ++){
        if(a[i] != '?' && a[i] != b[c])
            return 0;
        c ++;
    }
    return 1;
}
string fn(int l , int r){
    int c = 1;
    string ans = "";

    for(int i = 1; i <= strlen(a + 1); i ++)
        ans += a[i] == '?' ? 'a' : a[i];

    for(int i = l - 1; i < r; i ++)
        ans[i] = b[c ++];

    return ans;
}
main()
{
    scanf("%s" , a + 1);
    scanf("%s" , b + 1);
    int n = strlen(a + 1);
    int m = strlen(b + 1);
    if(m > n)
        return cout << "UNRESTORABLE" , 0;

    vector<string > vc;
    for(int i = 1; i <= n - m + 1; i ++){
        if(fun(i , i + m - 1)){
            vc.push_back(fn(i , i + m - 1));
        }
    }

    if((int)vc.size() == 0)
        return cout << "UNRESTORABLE" , 0;

    sort(vc.begin() , vc.end());
    cout << vc[0];
}


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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n, m;
    int k = 1;
    scanf("%d %d", &n, &m);
    rep(i, 0, m){
        k *= 2;
    }
    printf("%d", ((n-m)*100 + m*1900) * k );

    return 0;
}

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

#define LL long long
#define pa pair<int,int>
using namespace std;
const int inf = 2147483647;
const int N = 100001;

int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int a[N * 2];

int main() {
	int n = read(), M = read();
	for(int i = 1; i <= n * 2; i++) a[i] = read() % M;
	sort(a + 1, a + n * 2 + 1);
	int l = 0, r = n - 1, ans = n;
	while(l <= r) {
		int mid = (l + r) / 2; bool bk = 0;
		for(int i = mid * 2 + 1, j = n * 2; i < j; i++, j--) if(a[i] + a[j] < M) {bk = 1; break;}
		if(bk) l = mid + 1;
		else r = mid - 1, ans = mid;
	} int mx = 0;
	for(int i = 1; i <= ans; i++) mx = _max(mx, a[i] + a[ans * 2 - i + 1]);
	for(int i = ans * 2 + 1, j = n * 2; i < j; i++, j--) mx = _max(mx, a[i] + a[j] - M);
	printf("%d\n", mx);
	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int a[10];
int main(){
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  int i=0;
  if(a[i]==1 && a[i+1]==1){
    cout<<"Open"<<endl;
  }else{
    if(a[i+2]==1){
      cout<<"Open"<<endl;
    }else{
      cout<<"Close"<<endl;
    }
  }
  return(0);
}  



Measured memory_bytes: 3100
n = int(input())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]

key_p = [int(y) for y in range(1, n+1)]
key_q = [int(y) for y in range(1, n+1)]
value = 1
for i in range(1, n):
  value *= i

value_p = value
value_q = value

rank_p = 1
rank_q = 1

for i in range(n):
  for j in range(len(key_p)):
    if p[i] == key_p[j]:
      rank_p += (value_p*j)
      key_p.pop(j)
      if value_p != 1:
        value_p //= (n-i-1)
      break
    else:
      continue

for i in range(n):
  for j in range(len(key_q)):
    if q[i] == key_q[j]:
      rank_q += (value_q*j)
      key_q.pop(j)
      if value_q != 1:
        value_q //= (n-i-1)
      break
    else:
      continue
print(abs(rank_p-rank_q))

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

int main() {
  std::string s;
  std::cin >> s;
  int anum, znum;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'A') {
      anum = i;
      break;
    }
  }
  for (int i = s.size()-1; i >= 0; i--) {
    if (s.at(i) == 'Z') {
      znum = i;
      break;
    }
  }
  std::cout << znum - anum + 1 << '\n';
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int over = b - a;
		if (over <= 0){
			System.out.println("delicious");
		} else if (x >= over){
			System.out.println("safe");
		} else {
			System.out.println("dangerous");
		}

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	cin >> n;
	ll a, b;
	cin >> a >> b;
	ll res = 0;
	for (ll i = 1; i <= n; i++) {
		string s = to_string(i);
		ll tmp = 0;
		rep(j, s.size()) {
			ll k = s[j] - '0';
			tmp += k;
		}
		if (a <= tmp && tmp <= b) {
			res+=i;
		}
	}
	cout << res << endl;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static boolean a[][];
    static int h, w;
    public static void main(String[] args) throws IOException {
        BufferedReader input =
            new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer t = new StringTokenizer(input.readLine());
        h = Integer.parseInt(t.nextToken());
        w = Integer.parseInt(t.nextToken());

        a = new boolean[h+2][w+2];
        for (int i=1; i<=h; i++) {
            String s = input.readLine();
            for (int j=1; j<=w; j++) {
                a[i][j] = s.charAt(j-1) == '#';
            }
        }
        System.out.println(check() ? "Yes" : "No");
    }

    static boolean check() {
        for (int i=1; i<=h; i++) {
            for (int j=1; j<=w; j++) {
                if (a[i][j]) {
                    if (!round(i,j)) return false;
                }
            }
        }
        return true;
    }
    
    static boolean round(int i, int j) {
        if (a[i+1][j]) return true;
        if (a[i-1][j]) return true;
        if (a[i][j+1]) return true;
        if (a[i][j-1]) return true;
        return false;
    }
}


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

int solve(int a,int b,int c){
  if(b*b+a*a==c*c) return 1;
  else if(b*b+a*a>c*c) return 2;
  else if(b*b+a*a<c*c) return 3;
  return 0;
}

int main(){
  int a[3];
  int ans,ans1,ans2,ans3;
  bool flag=0;
  
  ans=ans1=ans2=ans3=0;
 
  while(cin>>a[0]>>a[1]>>a[2]){
    sort(a,a+3);
    // cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    if((a[0]+a[1])>a[2]&&(a[1]+a[2])>a[0]&&(a[0]+a[2])>a[1]&&flag==0){
      ans++;
      if(solve(a[0],a[1],a[2])==1) ans1++;
      else if(solve(a[0],a[1],a[2])==2) ans2++;
      else if(solve(a[0],a[1],a[2])==3) ans3++;
    }else flag=1 ;
  }
  cout<<ans<<" "<<ans1<<" "<<ans2<<" "<<ans3<<endl;
  return 0;
}

Measured memory_bytes: 1180
#include<stdio.h>
int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	S=S%3600;
	m=S/60;
	s=S%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}	

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N,K;
    cin>>N>>K;
    if(2*N<=K){
        cout<<N<<endl;
        return 0;
    }
    else if(N<=K){
        cout<<abs(N-K)<<endl;
        return 0;
    }
    long long a = N;
    while(1){
        a = a%K;
        if(a==0){
            cout<<0<<endl;
            return 0;
        }
        if(a<K){
            cout<<min((abs(a-K)),a)<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    x /= 200;
    x = 10-x;
    cout << x << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))  
#define lli long long int
#define ll long long 
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define BS binary_search
#define pii pair<lli,lli>
const long long int mod=1000000009;
//const long long int mod=998244353;
const long double PI=3.141592653589793;
const long long int inf=1e18;
const long long int inf2=LLONG_MAX;
#define setBitCount(x) __builtin_popcountll(x)
#define all(a) (a).begin(), (a).end()
#define all_r(a) (a).rbegin(), (a).rend()
lli gcd(lli a,lli b)
{
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
}
// calculating (x^y)%p
lli power(lli x,lli y,lli p)
{
    lli res = 1;      
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) //y is odd  
        res = (res*x) % p;
        y = y>>1; 
        x = ( (x%p)*(x%p) )% p;  
    }
    return res%p;
}
// calculating modular inverse using fermat little theorem
lli modInverse(lli n,lli p) 
{
    return power(n, p-2, p)%p;
}

// policy based data structures !!
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
// s.order_of_key (k) : Number of items strictly smaller than k
// *(s.find_by_order(k)) : K-th element in a set (counting from zero)
void solve()
{
   lli n;
   cin>>n;
   lli k;
   cin>>k;
   lli a[n+5];
   for(lli i=1;i<=n;i++)
   cin>>a[i];
   
   lli dp[k+5];
   mem(dp,0);
   
   for(lli i=1;i<=k;i++)
   {
      for(lli j=1;j<=n;j++)
      {
         if(i>=a[j])
         {
            if(dp[i-a[j]]==0)
            {
               dp[i]=1;
               break;
            }
         }
      }
   }
   if(dp[k]==1)
   cout<<"First";
   else
   cout<<"Second";
   
}
int main()
{
   
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    lli T;
    //cin>>T;
    T=1;
    while(T--)
    {
        solve();
    }




    return 0;
}

Measured memory_bytes: 1024
import collections

a = list(map(int,input().split()))
b = (map(int,input().split()))
c = (map(int,input().split()))
a.extend(b)
a.extend(c)
c = collections.Counter(a)
if c.most_common()[0][1]==2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3316
import java.util.*;

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

        Map<String, Integer> map = new HashMap<>();
        map.put("I", 1);
        map.put("V", 5);
        map.put("X", 10);
        map.put("L", 50);
        map.put("C", 100);
        map.put("D", 500);
        map.put("M", 1000);

        while (sc.hasNext()) {
            String[] S = sc.next().split("");

            int[] nums = new int[S.length];

            for (int i = 0; i < S.length; i++) nums[i] = map.get(S[i]);

            int sum = 0;
            for (int i = 0; i < S.length - 1; i++) sum = (nums[i] < nums[i + 1])? sum - nums[i] : sum + nums[i];

            sum += nums[nums.length - 1];
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 25848
#include<iostream>
using namespace std;
string S;

int main(){
    int n;cin>>n;
    cin>>S;
    if(S.size() % 2 == 1){
        cout<<"No"<<endl;
    }else{
        bool flg = 0;
        int m = S.size()/2;
        for(int i=0;i<m;i++){
            if(S[i] != S[i+m])flg = 1;
        }
        if(flg == 1){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  cin>>a>>b>>c;
  if(a>=c)cout<<0<<endl;
  else if(a+b>=c)cout<<c - a<<endl;
  else cout<<"NA"<<endl;
  
}


Measured memory_bytes: 3176
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

#define loop(i, n) for (int i = 0; i < (int)n; i++)

using namespace std;
typedef pair<int, int> pint;

int main() {
    int n, k;
    cin >> n >> k;
    int d=0;
    while(n!=0){
        n /= k;
        d++;
    }   
    cout << d << endl;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    string s = to_string(N);
    bool flag = false;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '7'){
            flag = true;
            break;
        }
    }
    if(flag == true){
        cout << "Yes" << endl; 
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3696
#!/usr/bin/env pypy
from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from itertools import imap as map, izip as zip
from itertools import permutations
from __builtin__ import xrange as range
from math import ceil
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from math import log, ceil, floor
from bisect import bisect, insort, bisect_left, bisect_right
from heapq import heapify, heappop, heappush
import sys
import os
import re
inf = float('inf')
mod = int(1e9) + 7
mod_ = 998244353
 
'''

!!!!!!!!!!!!!!!!!!!!!!!!   WAIT FFS    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
DONOT SUBMIT RECKLESSLY
One wrong submission = 10 mins penalty!
Check for special cases (n=1)

'''


def printGrid(grid):
	for row in grid:
		print(' '.join(list(map(str, row))))

def main():
	n, m = map(int, input().split())
	grid = [list(input()) for i in range(n)]
	dp = [[0]*m for i in range(n)]
	for i in range(m):
		if grid[0][i] == '#':
			for j in range(i, m):
				dp[0][j] = 0
			break
		dp[0][i] = 1

	for i in range(n):
		if grid[i][0] == '#':
			for j in range(i, n):
				dp[j][0] = 0
			break
		dp[i][0] = 1

	for i in range(1, n):
		for j in range(1, m):
			if grid[i][j] == '.':
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod

	print(dp[-1][-1])

# Fast IO
BUFSIZE = 8192
class FastI(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = StringIO()
		self.newlines = 0
 
	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()
 
	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count("\n") + (not b)
			ptr = self._buffer.tell()
			self._buffer.seek(0, 2), self._buffer.write(
				b), self._buffer.seek(ptr)
		self.newlines -= 1
		return self._buffer.readline()
class FastO(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = __pypy__.builders.StringBuilder()
		self.write = lambda s: self._buffer.append(s)
 
	def flush(self):
		os.write(self._fd, self._buffer.build())
		self._buffer = __pypy__.builders.StringBuilder()
def print(*args, **kwargs):
	sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop("end", "\n"))
	if kwargs.pop("flush", False):
		file.flush()
def gcd(x, y):
	while y:
		x, y = y, x % y
	return x
sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
	def bootstrap(cont):
		call, arg = cont.switch()
		while True:
			call, arg = cont.switch(to=continulet(
				lambda _, f, args: f(*args), call, arg))
	cont = continulet(bootstrap)
	cont.switch()
	main()

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

#define pb push_back
#define ff first
#define ss second
#define N 100005
#define inf 1000000009
#define ll long long
#define all(a) a.begin(),a.end()
#define mid(a,b) (a+b)/2
#define pii pair<int,int>

using namespace std;

int a,b,c,d,now;

int main()
{
	cin >> a >> b >> c >> d;
	while(a > 0 and c > 0){
		if(now % 2 == 0) c -= b;
		else a -= d;
		now++;
	}
	if(a <= 0) cout << "No";
	else cout << "Yes";
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

//  Binary Indexed Tree
class BIT
{
    int n;
    vector<int> v;
public:
    BIT(int n_) {
        n = 1;
        while (n < n_)
            n <<= 1;
        v = vector<int>(n);
    }
    //  a[i] += x
    void add(int i, int x) {
        for (; i<n; i|=i+1)
            v[i] += x;
    }
    //  return a[0]+a[1]+…+a[i-1]
    int sum(int i) {
        int s = 0;
        for (i--; i>=0; i=(i&(i+1))-1)
            s += v[i];
        return s;
    }
};

//  a^b % m
long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

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

    vector<int> x(N), y(N);
    for (int i=0; i<N; i++)
        cin>>x[i]>>y[i];

    set<int> sx, sy;
    for (int i=0;i<N; i++)
        sx.insert(x[i]),
        sy.insert(y[i]);
    map<int, int> mx, my;
    for (int tx: sx)
    {
        int t = mx.size();
        mx[tx] = t;
    }
    for (int ty: sy)
    {
        int t = my.size();
        my[ty] = t;
    }
    for (int i=0; i<N; i++)
        x[i] = mx[x[i]],
        y[i] = my[y[i]];

    //for (int i=0; i<N; i++)
    //    cout<<x[i]<<" "<<y[i]<<endl;

    vector<int> rx(N), ry(N);
    for (int i=0; i<N; i++)
    {
        rx[x[i]] = i;
        ry[y[i]] = i;
    }

    vector<long long> ne(N), nw(N), se(N), sw(N);

    BIT bit(N);
    for (int i=0; i<N; i++)
    {
        int p = ry[i];
        ne[p] = bit.sum(x[p]);
        nw[p] = i - ne[p];
        bit.add(x[p], 1);
    }
    bit = BIT(N);
    for (int i=N-1; i>=0; i--)
    {
        int p = ry[i];
        se[p] = bit.sum(x[p]);
        sw[p] = N-i-1 - se[p];
        bit.add(x[p], 1);
    }

    long long M = 998244353;
    long long ans = 0;

    for (int i=0; i<N; i++)
    {
        //cout<<ne[i]<<" "<<nw[i]<<" "<<se[i]<<" "<<sw[i]<<endl;

        long long t =
            + (powmod(2, ne[i]+nw[i], M) + M - 1)
            + (powmod(2, se[i]+sw[i], M) + M - 1)
            + (powmod(2, ne[i]+se[i], M) + M - 1)
            + (powmod(2, nw[i]+sw[i], M) + M - 1)
            - (powmod(2, ne[i], M) + M - 1)
            - (powmod(2, se[i], M) + M - 1)
            - (powmod(2, nw[i], M) + M - 1)
            - (powmod(2, sw[i], M) + M - 1);
        t = (t+M*10)%M;
        ans += t;
        ans %= M;
    }
    ans = (powmod(2, N, M)+M-1)*N - ans;
    ans = (ans%M+M)%M;

    cout<<ans<<endl;
}


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

using namespace std;

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl

const int maxn = (int)1e6+5;
typedef long long ll;

int cnt[maxn];
bool visited[maxn];
void solve(){

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

   int ans = 0;
   for(int i=1 ; i<=n ; i++){
      int val = a[i];
      if(visited[val]){
         cnt[val]=1;
         continue;
      }
      visited[val]=1;
      for(int j=val+val ; j<maxn ; j+=(val)){
         cnt[j]++;
      }
   }

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

      if(cnt[a[i]]==0) ans++;
   }

   cout << ans << endl;

}


int main()
{
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //cout << "Fi Amanillah" << endl;

    int t=1;
    //cin >> t;
    while(t--){
      solve();
    }
    return 0;
}



Measured memory_bytes: 9164
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} ;
// } fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	int r, l;
	int res = 0;
	vector<int> A, ans;
	vector<vector<int>> dp;
	vector<pair<int,int>> hoge;
	
	cin>>N;
	
	r = N-1;
	l = 0;
	
	A.resize(N);
	ans.resize(N);
	hoge.resize(N);
	dp.resize(N+1, vector<int>(N+1));
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		hoge[i] = {A[i], i};
	}
	
	sort(hoge.begin(), hoge.end(), greater<pair<int,int>>());
	
	for(int i = 0; i < N; i++){
		
		for(int j = 0; j <= i; j++){
			int a = j, b = N + j - i;
			// cout<<"i = "<<i<<" a = "<<a<<" b = "<<b<<endl;
			dp[a+1][b] = max(dp[a][b] + hoge[i].first * abs(a-hoge[i].second), dp[a+1][b]);
			dp[a][b-1] = max(dp[a][b] + hoge[i].first * abs(b-1-hoge[i].second), dp[a][b-1]);
		}
		// cout<<endl;
	}
	
	for(int j = 0; j <= N; j++){
		int a = j, b = j;
			// cout<<"i = "<<j<<" a = "<<a<<" b = "<<b<<endl;
		res = max(res, dp[a][b]);
	}
	
	cout<<res<<endl;
	
	return 0;
}


Measured memory_bytes: 34680
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

struct input {
	ll L, R, C;
	bool operator<(const input& another) const
	{
		if (L < another.L) { return true; }
		if (L > another.L) { return false; }
		return R < another.R;
	};
};

template<typename T>
struct SegmentTree {
private:
	ll n;
	vector<T> node;

	T init_v;

public:

	SegmentTree(vector<T> a, T _init_v) {
		ll sz = a.size();
		n = 1;
		init_v = _init_v;

		while (n < sz) n *= 2;
		node.resize(2 * n, init_v);
		for (ll i = 0; i < sz; i++) node[i + n - 1] = a[i];
		for (ll i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}

	void update(ll pos, T v) {
		ll k = pos + n - 1;
		node[k] = v;
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = min(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}

	T get(ll pos) {
		ll k = pos + n - 1;
		return node[k];
	}

	T query(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
		if (r < 0) r = n;
		if (r <= a || b <= l) return init_v;
		if (a <= l && r <= b)return node[k];
		T lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T rv = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(lv, rv);
	}

};

int main() {
	ll N, M; cin >> N >> M;

	vector<input> v;
	for (ll i = 0; i < M; i++) {
		input IN;
		cin >> IN.L >> IN.R >> IN.C;
		v.push_back(IN);
	}

	sort(v.begin(), v.end());

	vector<ll> _v;
	for (ll i = 0; i <= N; i++) {
		_v.push_back((ll)10000000000000002);
	}

	SegmentTree<ll>	ST(_v, (ll)10000000000000002);

	ST.update(1, 0);

	for (auto itr = v.begin(); itr != v.end(); itr++) {
		ll s = ST.query(itr->L, itr->R);
		s += itr->C;
		s = min(ST.get(itr->R), s);
		ST.update(itr->R, s);
	}
	ll j = ST.get(N);
	if (j == (ll)10000000000000002) { cout << -1 << endl; }
	else { cout << j << endl; }

	return 0;
}


Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 1000000000
#define pi 3.14159265358979323846264338327950L
#define FOR(i,a,b) for(int i=a;i<=b;i++)
int main()
{
    //freopen("contest.txt","r",stdin);
    //freopen("contest.txt","w",stdout);
    IOS
    ll X,x,count_0=0;
    x=100;
    ll r=x/100;
    cin>>X;
    while(x<X)
    {
        x+=r;
        count_0++;
        r=x/100;
    }
    cout<<count_0<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

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

	cin >> N;
	vector<long long int>v(N);
	for (auto&i : v)cin >> i;
	int minus = 0;
	for (int i = 0; i < N - 1; i++) {
		minus += min(v[i], v[i + 1]);
	}
	cout << accumulate(v.begin(), v.end(), 0) - minus << endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc169/tasks/abc169_b
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)

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

  ll ans = 1;
  REP(i, N) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << 0;
      return 0;
    }
    if (ans > ll(2e18) / a) {
      ans = 2e18;
    } else
      ans *= a;
  }
  if (ans > ll(1e18)) {
    cout << -1;
    return 0;
  }
  cout << ans;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int const inf = numeric_limits<int>::max();

template<class T>
struct SegmentTree {
    int n;
    vector<T> dat;
    SegmentTree(int n_ = 0) : n(n_){
        n = 1;
        while(n < n_) n <<= 1;
        dat.resize(n*2, inf);
    }
    T query(int v, int w, int l, int r){
        if(r <= l || w == 0) return inf;
        if(l + w == r) return dat[v];
        return min(query(v<<1, w/2, l, min(r, w/2)),
                   query(v<<1|1, w/2, max(0, l-w/2), r-w/2));
    }
    void update(int i, T x){
        i += n;
        dat[i] = x;
        for(; i!=1; i>>=1) dat[i>>1] = min(dat[i], dat[i^1]);
    }
    T query(int l, int r){
        return query(1,n,l,r);
    }
    size_t size() const {
        return n;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, q;
    while(cin >> n >> q){
        SegmentTree<int> st(n);
        while(q--){
            char c;
            int x, y;
            cin >> c >> x >> y;
            if(c == '0'){
                st.update(x,y);
            } else {
                cout << st.query(x,y+1) << '\n';
            }
        }
    }
}

Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
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() {
  ll n; string s;
  cin >> n >> s;
  if(n%2 == 1){
    cout << "No" << endl;
    return 0;
  }
  
  string t,u;
  rep(i, n/2)
    t.push_back(s.at(i));
  for(ll i=n/2; i<n; i++)
    u.push_back(s.at(i));
  
  if(t == u)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3572
import java.io.FileNotFoundException;
import java.util.Scanner;

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

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int H1 = sc.nextInt();
    	int M1 = sc.nextInt();
    	int H2 = sc.nextInt();
    	int M2 = sc.nextInt();
    	int K = sc.nextInt();

    	int length = H2*60+M2-(H1*60+M1);

    	System.out.println(length-K);

    }
}

Measured memory_bytes: 27100
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#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 fi first
#define se second
//INF = 1 061 109 567 ; INF + INF = 2 122 219 134 ;
//LINF = 4 557 430 888 798 830 399 ; LINF + LINF = 9 114 861 777 597 660 798 ;
const int INF = 0x3f3f3f3f;     // -INF: 0xc0   abs(-INF) = INF + 1
const ll LINF = 0x3f3f3f3f3f3f3f3f;
/*}}}*/                         // zr, zm
const int MOD = (int)1e9+7;     // when MOD = 1e9+7, inv2 = 500000004
const int N = (int)1e6+7;
const int M = (int)-1;
char s[N],t[N];
int nxt[N][27],p[27];
int main()
{
	scanf("%s%s",s,t);
	int ls = strlen(s);
	memset(p,-1,sizeof(p));
	per(i,0,ls) {
		p[s[i]-'a'] = i;
	}
	per(i,0,ls) {
		rep(j,0,26) nxt[i][j] = p[j];
		p[s[i]-'a'] = i;
	}
	int ans = 0,j = p[t[0]-'a'];
	for(int i = 1;t[i] && j != -1;i++) {
		if(nxt[j][t[i]-'a'] <= j) ans++;
		j = nxt[j][t[i]-'a'];
	}
	if(j == -1) printf("-1");
	else printf("%lld\n",(ll)ans*ls+j+1);
	return 0;
}


Measured memory_bytes: 14592
#include<stdio.h>
int main()
{
    int a,b;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        if(a+b==15)
        {
            printf("+\n");
        }
        else if((a*b)==15)
        {
            printf("*\n");
        }
        else{
            printf("x\n");
        }
    }

}


Measured memory_bytes: 128
n,c= map(int,input().split())
nca = sorted([tuple(map(int,input().split())) for _ in range(n)])
cnf = [True]*n
line=0
while any(cnf):
    lst = ()
    for i in range(n):
        if cnf[i]==True:
            temp = nca[i]
            if (lst == ()) or (temp[2]==lst[2]) or (lst[1] < temp[0]):
                lst = temp
                cnf[i]=False
    line+=1
print(line)

Measured memory_bytes: 18592
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<string> vs;
#define ifr(i,n) for((i)=0;(i)<(n);i++)
#define dfr(i,n) for((i)=(n);(i)>=0;i--)
/*
char upper(char C){
  if('a'<=C && C<='z')
    C = C-32;
  return C;
}
*/
char upper(char C){
   if(C >= 'a' && C <= 'z')
	C = C + 'A' - 'a';
   return C;
}
int main(){
  string str;
  string str2;
  int num=0;
  cin>>str2;
  for(int i=0;i<str2.size();i++)
    str2[i]=upper(str2[i]);
  while(cin>>str,str!="END_OF_TEXT"){
  for(int j=0;j<str.size();j++)
    str[j]=upper(str[j]);
  if(str[str.size()-1]=='.')
    str=str.substr(0,str.size()-1);
  if(str == str2)
    num++;
  }
  cout << num<<endl;
  return 0;
}

Measured memory_bytes: 3140
#include<stdio.h>
int N,i,j,k,C[1005],dp[1005][9]={0},r=0;//J=2^0 O=2^1 I=2^2
char c;
int main()
{
	scanf("%d\n",&N);
	for(i=1;i<=N;i++)
	{
		scanf("%c",&c);
		C[i]=c=='J'?0:c=='O'?1:2;
	}
	dp[0][1]=1;
	for(i=1;i<=N;i++)
		for(j=1;j<8;j++)//next
			if(j&(1<<C[i]))
				for(k=1;k<8;k++)//now
					if((j&k)!=0)
						dp[i][j]=(dp[i][j]+dp[i-1][k])%10007;
	for(i=0;i<8;i++)
		r=(r+dp[N][i])%10007;
	printf("%d\n",r);
	return 0;
}

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

int main(){
  int h,w;
  while(cin>>h>>w, h+w){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(((i+j)&1) == 0)
	  cout<<"#";
	else
	  cout<<".";
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}

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

#define endl '\n'
using namespace std;
using ll = long long;

struct Node
{
    ll val;
    ll tag;
};

class Seg1D
{
private:
    static const int N = 200005;
    static const ll INF = 1ll<<60;
    int _n;
    Node st[N*4];
    void _down(Node &p, Node &lson, Node &rson)
    {
        p.val += p.tag;
        lson.tag += p.tag;
        rson.tag += p.tag;
        p.tag = 0;
    }
    void _up(Node &p, Node &lson, Node &rson)
    {
        assert(p.tag == 0);
        p.val = max(lson.val + lson.tag, rson.val + rson.tag);
    }
    void _build(int l, int r, int idx, ll *arr)
    {
        st[idx].tag = 0;
        if(l == r) 
        {
            st[idx].val = arr[l]; return;
        }
        int mid = (l+r)/2, lson = idx*2, rson = lson+1;
        _build(l, mid, lson, arr);
        _build(mid+1, r, rson, arr);
        _up(st[idx], st[lson], st[rson]);
    }
    ll _query(int l, int r, int idx, int L, int R)
    {
        if(r < L || R < l) return -INF;
        int mid = (l+r)/2, lson = idx*2, rson = idx*2+1;
        if(L <= l && r <= R) return st[idx].val + st[idx].tag;
        _down(st[idx], st[lson], st[rson]);
        return max(_query(l, mid, lson, L, R), _query(mid+1, r, rson, L, R));
    }
    void _modify(int l, int r, int idx, int L, int R, ll val)
    {
        if(r < L || R < l) return;
        if(L <= l && r <= R)
        {
            st[idx].tag += val; return;
        }
        int mid = (l+r)/2, lson = idx*2, rson = idx*2+1;
        _down(st[idx], st[lson], st[rson]);
        _modify(l, mid, lson, L, R, val);
        _modify(mid+1, r, rson, L, R, val);
        _up(st[idx], st[lson], st[rson]);
    }
public:
    void build(int n) { _n = n; }
    void build(ll *arr, int n) { _n = n, _build(0, n-1, 1, arr); }
    ll query(int l, int r) { return _query(0, _n-1, 1, l, r); }
    void modify(int l, int r, ll val) { _modify(0, _n-1, 1, l, r, val); }
};

const int N = 200005;

struct Interval
{
    int l, r;
    ll val;
};

int n, m;
Interval arr[N];
vector<int> isStart[N], isEnd[N];
Seg1D st; 

void init();
void process();

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> m;
    for(int i = 0; i < m; i++) 
    {
        cin >> arr[i].l >> arr[i].r >> arr[i].val;
        isStart[arr[i].l].emplace_back(i);
        isEnd[arr[i].r].emplace_back(i);
    }
    st.build(n+1);
}

void process()
{
    for(int i = 1; i <= n; i++)
    {
        for(auto idx : isStart[i])
        {
            const auto &interval = arr[idx];
            st.modify(0, interval.l-1, interval.val);
        }
        ll dpi = st.query(0, i-1);
        st.modify(i, i, dpi);
        for(auto idx : isEnd[i])
        {
            const auto &interval = arr[idx];
            st.modify(0, interval.l-1, -interval.val);
        }
    }
    cout << st.query(0, n) << endl;
}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    int x,y;
    cin >> x >> y;
    if((x+y)%3) {
        cout << 0 << endl;
        return 0;
    }
    int m = 2*x/3-y/3;
    int n = x - 2*m;
    combination comb(x+y);
    mint ans = comb(m+n,n);
    cout << ans.x << endl;
}



Measured memory_bytes: 34340
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    int count=0,ans=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='A' ||S[i]=='C'||S[i]=='G'||S[i]=='T')count++;
        else count=0;
        ans=max(ans,count);
    }
    cout<<ans<<endl;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int N;
    cin >> N;
    if(N%2 == 0) cout << N << endl;
    else cout << N*2 << endl;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll N;
  cin>>N;
  vector<ll> A(N),B(N);
  for(ll i = 0LL; i < N;i ++) cin>>A[i];
  for(ll i = 0LL; i < N;i ++) cin>>B[i];
  unordered_map<ll,bool> m;
  vector<ll> hi(N);
  for(ll i = 0LL; i < N; i++){
    hi[i]=A[i];
    if(i==0){
      m[i]=true;
    }
    if(i!=0){
      if(A[i]!=A[i-1]) m[i]=true;
    }
  }
  bool can = true;
  for(ll i = N-1; i >= 0; i--){
    if(i==N-1){
      if(m[i]&&hi[i]!=B[i]){
        can = false;
        break;
      }
      if(B[i]>hi[i]){
        can = false;
        break;
      }
      m[i]=true;
    }
    if(i!=N-1){
      if(B[i]!=B[i+1]){
        if(m[i]&&hi[i]!=B[i]){
          can = false;
          break;
        }
        if(B[i]>hi[i]){
          can = false;
          break;
        }
        m[i]=true;
      }
    }
    chmin(hi[i],B[i]);
  }
  ll ans = 1LL;
  if(can){
    for(ll i = 0LL; i < N; i++){
      if(m[i]) continue;
      ans=(ans*hi[i])%mod;
    }
    cout<<ans<<endl;
  }
  else {
    cout<<0<<endl;
  }
}

Measured memory_bytes: 6692
#include<stdio.h>
int main(){
    int x,a,b;
    int d1,d2;
    scanf("%d %d %d",&x,&a,&b);
    d1=x-a;
    d2=x-b;
    if(d1<0){
        d1*=-1;
    }
    if(d2<0){
        d2*=-1;
    }
    if(d1>d2){
        printf("B");
    }else{
        printf("A");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define For(i,x) for (i=0;i<x;i++)
int main()
{
	int i,j,k,n,b,f,r,v;
	int count[4][3][10];
	For (i,4) For (j,3) For (k,10) count[i][j][k]=0;
	scanf("%d",&n);
	For (i,n) {
		scanf("%d%d%d%d",&b,&f,&r,&v);
		count[b-1][f-1][r-1]+=v;
	}
	For (i,4) {
		For (j,3) {
			For (k,10) {
				printf(" %d",count[i][j][k]);
			}
			printf("\n");
		}
		if (i!=3) printf("####################\n");
	}
	return 0;
}

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

int main(){
    string a, b;
    cin>>a>>b;
    int c=0;
    for(int i=0; i<a.size(); i++){
        if(a[i]!=b[i]){
            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
    int n;
    scanf("%lld",&n);
    int ans = 1000000000001;
    for (int i = 1; i*i <= n; i++){
        if (n % i == 0){
            ans = min(ans,i+n/i);
        }
    }
    printf("%lld ",ans-2);

}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

char s[125252];

int main(){
  scanf("%s",s);
  int n = strlen(s);
  int ans = n;
  REP(x,2){
    int t = 0;
    REP(i,n){
      int v = (i+x)%2;
      if(s[i]!='0'+v)t++;
    }
    CHMIN(ans,t);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384