akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
#define INF 3000000000000000000LL
#define MO 1000000007
using namespace std;
typedef long long LL;
LL f[MAXN+5],g[MAXN+5];
LL sumf[MAXN+5],sumg[MAXN+5];
LL N,A,B,a[MAXN+5];
int main()
{
//	freopen("division.in","r",stdin);
//	freopen("division.out","w",stdout);
	scanf("%lld %lld %lld",&N,&A,&B);
	for(int i=1;i<=N;i++)
		scanf("%lld",&a[i]);
	a[N+1]=INF;
	a[0]=-INF;
	int pA=0,pB=0,pmidA=0,pmidB=0;
	sumf[2]=sumg[2]=f[0]=g[0]=1;
	for(int i=1;i<=N;i++)
	{
		if(a[i]-a[i-1]<A)
			pmidA=i;
		if(a[i]-a[i-1]<B)
			pmidB=i;
		while(a[i+1]-a[pA+1]>=A)	pA++;
		while(a[i+1]-a[pB+1]>=B)	pB++;
		if(pA==i)	pA--;
		if(pB==i)	pB--;
		int lA=pmidA-1;
		int rA=pB;
		int lB=pmidB-1;
		int rB=pA;
		if(lA<=rA)
			f[i]=(sumg[rA+2]-sumg[lA-1+2]+MO)%MO;
		if(lB<=rB)
			g[i]=(sumf[rB+2]-sumf[lB-1+2]+MO)%MO;
		sumf[i+2]=(sumf[i-1+2]+f[i])%MO;
		sumg[i+2]=(sumg[i-1+2]+g[i])%MO;
	}
	LL ans=(f[N]+g[N])%MO;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4096
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    public void solve() {
    	int a = ni();
    	int b = ni();
    	String ans = "";
    	if(a <= b) {
    		for (int i = 0; i < b; i++) {
				ans += String.valueOf(a);
			}
    	}  else {
    		for (int i = 0; i < a; i++) {
    			ans += String.valueOf(b);
    		}
		}
    	out.println(ans);
    }
    // Set に入れるなら　PPKEY　を使う！
    static class PP{
    	public int key, val;
    	public PP(int key, int val) {
    		this.key = key;
    		this.val = val;
    	}
		public int getKey() {
			return key;
		}
		public void setKey(int key) {
			this.key = key;
		}
		public int getVal() {
			return val;
		}
		public void setVal(int val) {
			this.val = val;
		}
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
 
using namespace ::std;
 
#define all(x)  x.begin(),x.end()
#define Unique(x) x.erase(unique(all(x)), x.end())
 
template< class T > T SQR(T N) {return (T) N * N;}
template< class T > double DIST(T a, T b) {return 1.0 * sqrt(SQR(double(a)) + SQR(double(b)));}
template< class T > bool CROSS(pair< T,T > a, pair< T,T > b, pair< T,T > c) {return (b.first - a.first) * (c.second - b.second) >= (b.second - a.second) * (c.first - b.first);}
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int,int > pi;
 
int px[] = {0, 1, -1, 0, -1, -1, 1, 1};
int py[] = {1, 0, 0, -1, -1, 1, -1, 1};
 
double EPS = 1e-9;
double PI = acos(-1);
double GR = 1.6180339887498948;

vector< int >Pr;

inline void Seive()
{
    bool a[15007]{};
    Pr.push_back(2);
    for(int i = 4; i<=15005; i += 2) a[i] = 1;
    for(ll i = 3; i * i <(1505); i += 2) if(!a[i]) {for(ll j = i * i; j <= 15005; j = j + 2 * i) a[j] = 1;}
    for(int i = 3; i<= 15005; i += 2) if(!a[i]) Pr.push_back(i);
}
 
inline ll power(ll a, ll p, ll mod)
{
    ll x = a, res = 1;
 
    while(p)
    {
        if(p&1) res = (res * x)%mod;
        p /= 2, x = (x * x)%mod;
    }
    return res;
}
 
int F[207];
 
inline void Fail(string str)
{
    string s = str;
    reverse(all(s));
 
    s = s + "#" + str;
 
    int len = s.length();
 
    for(int i = 1; i<len; ++i)
    {
        int j = F[i - 1];
        while (j > 0 and s[i] != s[j])
            j = F[j - 1];
         if(s[i] == s[j]) ++j;
         F[i] = j;
    }
}
 
// ll Pow[500007];
// ll bit[500007];
// ll mod = 998244353LL;
 
// struct BIT
// {
//     inline void UPDATE(int idx, int n, int val)
//     {
//         for(int i = idx; i<=n; i += (i&-i))
//             bit[i] = (bit[i] + (Pow[idx] * val)%mod)%mod;
//     }
 
//     inline ll Sum(int idx)
//     {
//         ll ss = 0;
//         for(int i = idx; i; i -= (i & -i))
//             ss = (ss + bit[i])%mod;
//         return ss;
//     }
// };

// inline int SMALL_GIANT(ll a, ll rem, ll mod)
// {
//     a %= mod, rem %= mod;

//     ll k = 1, step = 0, gcd;
//     while((gcd = __gcd(a, mod)) > 1)
//     {
//         if(k == rem) return step;
//         if(rem%gcd) return -1;
//         rem /= gcd, mod /= gcd, ++step;
//         k = (k * (a/gcd))%mod;
//     }

//     int n = sqrt(mod) + 1;
//     unordered_map< int,int >mp;

//     ll xx = 1, cur = rem, xxx = k;
//     for(int i = 0; i<n; ++i) xx = (xx * a)%mod;

//     for(int q = 0; q <= n; ++q)
//         mp[cur] = q, cur = (cur * a)%mod;

//     for(int p = 1; p <=n; ++p)
//     {
//         xxx = (xxx * xx)%mod;
//         if(mp[xxx]) return p * n - mp[xxx] + step;
//     }
//     return -1;
// }

//vector< int >graph[200000];


int main()
{
    cin.tie(0); cout.tie(0);
 
    int n, m, c, d, a, b, k;
    int test;
    
    // scanf("%d", &test);
    // for(int t = 1; t<=test; ++t)
    // {
    //     scanf("%d%d", &k, &b);


    // }

    scanf("%d", &n);
    if(n >= 30) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] inputData = Console.ReadLine().Split(' ');

            int dataCnt = int.Parse(inputData[0]);
            int ratio = int.Parse(inputData[1]);

            int result = ratio;
            if (dataCnt < 10)
            {
                result = ratio + 100*(10 - dataCnt);
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int d = sc.NextInt();
        int n = sc.NextInt();

        int div = d == 0 ? 1 : (d == 1 ? 100 : 10000);

        int answer = div * n;
        if (n == 100)
        {
            answer += div;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1e9;
const int MAX_N = 8;

int n, A, B, C, ans = INF;
vector<int> l(MAX_N);  // l[i] : i番目の竹の長さ
vector<int> v(MAX_N);  /* v[i] : 0のときi番目の竹を長さAの竹の素材として使う。
                                 1のときはBの素材。2のときはCの素材。
                                 3のときは素材として使用しない。 */

void calc() {

    int now = 0;  // いま考えている状況で必要なMP
    int cntA = 0, cntB = 0, cntC = 0;  // cntAは長さAの竹の素材として使う竹の数
    int lA = 0, lB = 0, lC = 0;  // lAは長さAの竹の素材として使う竹の現在の長さ

    rep(i, n) {
        if(v[i] == 0) {
            cntA++;
            lA += l[i];
        }
        else if(v[i] == 1) {
            cntB++;
            lB += l[i];
        }
        else if(v[i] == 2) {
            cntC++;
            lC += l[i];
        }
    }

    if(cntA == 0 || cntB == 0 || cntC == 0) {  // いずれかの長さの竹の素材がない場合はダメ
        return;
    }

    now += 10*(cntA + cntB + cntC - 3);  // 合成魔法で消費するMP

    now += abs(A - lA) + abs(B - lB) + abs(C - lC);  // 延長 & 短縮魔法で消費するMP

    ans = min(ans, now);
}

void dfs(int depth) {

    if(depth == n) {
        calc();
        return;
    }

    rep(i, 4) {
        v[depth] = i;
        dfs(depth+1);
    }

}

int main() {

    cin >> n >> A >> B >> C;

    rep(i, n) {
        cin >> l[i];
    }

    dfs(0);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

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

  int rank = 1;
  while (n >= k) {
    n = n / k;
    rank += 1;
  }

  cout << rank << endl;

  return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
MOD = 10**9 + 7
ans = 0
for k in range(K, N + 2):
    ans = (ans + k * (2 * N - k + 1) // 2 - (k - 1) * k // 2 + 1) % MOD
print(ans)


Measured memory_bytes: 9168
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int ans=0;
    rep(i,3030)rep(j,3030){
        int sum=n-r*i-g*j;
        if(sum>=0&&sum%b==0)++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int SumDigit(int i){
  string s = to_string(i);
  int sum = 0;
  rep(j,s.size()){
    sum += s[j] - '0';
  }
  return sum;
}

int main() {
  int n,a,b; cin>>n>>a>>b;
  int ans = 0;
  for (int i=1; i<=n; i++){
    if (a<=SumDigit(i) && b>=SumDigit(i)) ans += i;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for (int i=a;i<(b);++i)
using namespace std;
typedef long long ll;
int main(){
  //競プロer解答閲覧解答
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
    cin >> s[i];
    rep(j,i){
      if(s[j]==s[i]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  rep(i,n-1){
    char back=s[i].at(s[i].size()-1),head=s[i+1].at(0);
    if(back!=head){
      cout <<"No"<<endl;
      return 0;
    }
  } 
  cout << "Yes" << endl;
  return 0;
}
    

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



int main(){

	long long N;
	cin>>N;
	int X,M;
	cin>>X>>M;
	vector<vector<pair<int,long long>>> nxt(40,vector<pair<int,long long>>(M));
	
	rep(i,40){
		rep(j,M){
			if(i==0){
				nxt[i][j] = make_pair(((long long)j*j)%M,((long long)j*j)%M);
			}
			else{
				nxt[i][j] = make_pair(nxt[i-1][nxt[i-1][j].first].first, nxt[i-1][j].second + nxt[i-1][nxt[i-1][j].first].second);
			}
			
			
		}
	}
	/*
	rep(i,5){
		rep(j,10){
			cout<<i<<','<<j<<','<<nxt[i][j].first<<','<<nxt[i][j].second<<endl;
		}
	}
	*/

	int now = X%M;
	long long ans = now;
	N--;
	
	rep(i,40){
		if((N>>i)&1){
			ans += nxt[i][now].second;
			now = nxt[i][now].first;
		}
	}
	
	cout<<ans<<endl;

	return 0;
}



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

long long maxi = 0;
long long N;
long long M;
long long Q;
std::vector<long long> a;
std::vector<long long> b;
std::vector<long long> c;
std::vector<long long> d;

void dfs(vector<long long> &v, long long start)
{
    if (v.size() == N) {
        long long sum = 0;
        for (long long i = 0; i < Q; i++) {
            if (v[b[i] - 1] - v[a[i] - 1] == c[i]) {
                sum += d[i];
            }
        }
        if (sum >= maxi) {
            maxi = sum;
        }
        return;
    }
    for (long long i = start; i <= M; i++) {
        v.push_back(i);
        dfs(v, i);
        v.pop_back();
    }
}

int main(){
    scanf("%lld",&N);
    scanf("%lld",&M);
    scanf("%lld",&Q);
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
    }
    vector<long long> v;
    dfs(v, 1);
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 3688
#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, m, x, y; cin >> n >> m >> x >> y;
    int x_max;
    rep(i, n) {
        if (i == 0)
            cin >> x_max;
        else {
            int tmp;
            cin >> tmp;
            x_max = max(x_max, tmp);
        }
    }
    int y_min;
    rep(i, m) {
        if (i == 0)
            cin >> y_min;
        else {
            int tmp;
            cin >> tmp;
            y_min = min(y_min, tmp);
        }
    }

    for (int i = x+1; i <= y; i++) {
        if (x_max < i && i <= y_min) {
            puts("No War");
            return 0;
        }
    }
    puts("War");
    return 0;
}

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

int main() {
	int r, D, X;
	cin >> r >> D >> X;
	vector<int> vec(10);
	for (int i = 0; i < 10; i++) {
		vec.at(i) = r * X - D;
		X = vec.at(i);
	}
	for (int j = 0; j < 10; j++) {
		cout << vec.at(j) << endl;
	}
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ii pair<int,int>
#define st first
#define nd second
#define N 200005
#define inf 1000000000
#define MOD 998244353
#define sz(x) ((int)x.size())
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
using namespace std;

int n,q;
int tot[N];
vector<int> v[N];

void dfs(int node,int dad) {

	for(int i:v[node]) {

		if(i==dad) continue ;

		tot[i]+=tot[node];

		dfs(i,node);

	}

}

int main(int arg,char* argv[]) {

	cin>>n>>q;

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

		int x,y;

		cin>>x>>y;

		v[x].pb(y);
		v[y].pb(x);

	}

	while(q--) {

		int a,b;

		cin>>a>>b;

		tot[a]+=b;

	}

	dfs(1,0);

	for(int i=1;i<=n;i++) cout<<tot[i]<<' ';

}

Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll s;
ll a=1e9;
ll b;
ll t=1;
ll u;
int main(){
	cin>>s;
	u=1e9-(s%((ll)1e9));
	b=(s+u)/a;
	if(s==1e18){
		a=1e9;
		b=1e9;
		u=0;
		t=0;
	}
	cout<<0<<" "<<0<<" "<<a<<" "<<u<<" "<<t<<" "<<b<<endl;
	return 0;
}

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

#include <math.h>
#include <stdlib.h>


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

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int taste[3005][3005];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, t;
    cin >> n >> t;

    vector<pair<int, int>> food(n);
    for(int i = 0; i < n; i++){
        cin >> food[i].first >> food[i].second;
    }

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

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < t; j++){
            // 食べない時
            taste[i+1][j] = max(taste[i+1][j], taste[i][j]);

            // 食べるときは食べてもt秒未満に終わること
            int tt = j + food[i].first;
            if(tt < t){
                taste[i+1][tt] = max(taste[i+1][tt], taste[i][j] + food[i].second);
            }
        }
        ans = max(ans, taste[i][t-1] + food[i].second);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35456
N = int(input())
hList = [int(x) for x in input().split()]

count = 0
for i,h in enumerate(hList):
    ng = False
    for j in range(i+1):
        if hList[j] > h:
            ng = True
            break
    if ng == False:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>	
#include <utility>
#include <cinttypes>
#include <string>
#include <iostream>
#include <cmath>
#include<iomanip>
using namespace std;

int main(){
    cout<<std::fixed<<setprecision(10);
    cin.tie(0);
   	ios::sync_with_stdio(false);
    long long r,d,x;
    cin>>r;
    cin>>d;
    cin>>x;
    for (int i=1;i<=10;i++){
        x = r*x-d;
        cout<<x<<"\n";
    }
}

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

int main() {
  size_t n;
  cin >> n;
  set<int> st;
  rep(i,n) {
    int x;
    cin >> x;
    st.insert(x);
  }
  if (st.size() == n) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 12976
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<string>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

string S;
string T;
int A[100100];
int B[100100];
int C[100100];
int D[100100];
int SA[100100];
int TA[100100];

string subS(int a, int b) {
    return S.substr(a - 1, (b - a) + 1);
}

string subT(int c, int d) {
    return T.substr(c - 1, (d - c) + 1);
}

int AB(string s) {
    int a = 0, b = 0;
    rep(i, s.size()) {
        if (s[i] == 'A')++a;
        else ++b;
    }
    return (((a - b) % 3) + 3) % 3;
}

signed main() {
    cin >> S >> T;
    int Q;
    cin >> Q;
    rep(i, Q) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--;
        B[i]--;
        C[i]--;
        D[i]--;
        //0-indexed
    }
    rep(i, S.size()) {
        SA[i + 1] = SA[i] + (S[i] == 'A');
    }
    rep(i, T.size()) {
        TA[i + 1] = TA[i] + (T[i] == 'A');
    }
    rep(i, Q) {
        int sa = SA[B[i] + 1] - SA[A[i]];
        int sb = B[i] - A[i] + 1 - sa;
        int ta = TA[D[i] + 1] - TA[C[i]];
        int tb = D[i] - C[i] + 1 - ta;
        int sab = (sa - sb) % 3;
        if (sab < 0)sab += 3;
        int tab = (ta - tb) % 3;
        if (tab < 0)tab += 3;
        if (sab == tab) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5632
#include<stdio.h>
#include<stdlib.h>
long cmp(const void*a,const void *b){
  return *(long*)a - *(long*)b;
}

long gcdf(long a,long b){
  long p = a;
  long q = b;
  long c = 0;
  c = p%q;
  while(c != 0){
    p = q;
    q = c;
    c = p%q;
  }
  return q;
}
int main(){
  long n = 0;
  long x = 0;
  long a[100001]={};
  long diff[100000]={};
  long i = 0;
  long gcd = 0;
  scanf("%ld %ld",&n,&x);
  a[0] = x;
  for(i=0;i<n;i++){
    scanf("%ld",&a[i+1]);
  }
  qsort(a,n+1,sizeof(long),cmp);
  for(i=0;i<n;i++){
    diff[i] = a[i+1] - a[i];
    //printf("%ld/",diff[i]);
  }
  gcd = diff[0];
  //printf("%ld/",gcd);
  for(i=1;i<n;i++){
    gcd = gcdf(gcd,diff[i]);
   // printf("%ld/",gcd);
  }
  printf("%ld",gcd);
  return 0;
}
  
  
  
      

Measured memory_bytes: 2556
import kotlin.math.*
fun main(args: Array<String>) {
    val (a, b, c, d) = readLine()!!.split(" ").map(String::toInt)
    var hour = 30 * c + d * 0.5
    var minuets = d * 6.0
    var angle = hour - minuets
    if (angle >= 180) {
        angle = 360 - angle
    }
    val ans = a * a + b * b - 2 * a * b * cos(Math.toRadians(angle))
    println(sqrt(ans))
}

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

using namespace std;

int H,W,N;
int SX,SY;
int U,D,L,R;
int nu,nd,nl,nr;
char s[200005],t[200005];
int main() {
	scanf("%d%d%d%d%d",&H,&W,&N,&SX,&SY);
	scanf("%s%s",&s[1],&t[1]);
	U = D = SX; L = R = SY;
	nu = nd = SX; nl = nr = SY;
	for(int i=1;i<=N;i++) {
		if(s[i]=='U') {
			nu--; U = min(U,nu);
		} else if(s[i]=='D') {
			nd++; D = max(D,nd);
		} else if(s[i]=='L') {
			nl--; L = min(L,nl);
		} else {
			nr++; R = max(R,nr);
		}

		if(t[i]=='U') {
			nd  = max(1,nd-1);
		} else if(t[i]=='D') {
			nu = min(H,nu+1);
		} else if(t[i]=='L') {
			nr = max(1,nr-1);
		} else {
			nl=min(W,nl+1);
		}
	}
	if(U<=0||D>H||L<=0||R>W) puts("NO");
	else puts("YES");
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
#define YN(f) cout<<((f)?"Yes":"No")<<endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000; 
 

int main(){
	string s;
	cin>>s;
	s[3]='8';
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            //入力読取。
            string strHasLength = Console.ReadLine();
            int intHasLength = int.Parse(strHasLength);
            List<string> hasCardList = new List<string>();
            for (int first = 0; first < intHasLength; first++)
            {
                string strCard = Console.ReadLine();
                hasCardList.Add(strCard);
            }

            //全てのカードのリストを作成。
            List<string> allCardList = new List<string>();
            string[] markArray = {"S", "H", "C", "D" };
            for (int markIndex = 0; markIndex < markArray.Length; markIndex++)
            {
                for (int numIndex = 1; numIndex <= 13; numIndex++)
                {
                    string strCard = markArray[markIndex] + " " + numIndex;
                    allCardList.Add(strCard);
                }
            }

            //持っていないカードのリストを作成。
            List<string> nothingCardList = new List<string>();
            foreach (string targetCard in allCardList)
            {
                int intExist = hasCardList.IndexOf(targetCard);
                if (intExist < 0)
                {
                    nothingCardList.Add(targetCard);
                }
            }

            //出力。
            foreach (string nothingCard in nothingCardList)
            {
                Console.WriteLine(nothingCard);
            }
            Console.ReadKey();
        }
    }
}



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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, M, X;
    cin >> N >> M >> X;
    Vl C(N);
    vector<Vl> A(N, Vl(M));
    for (ll i = 0; i < N; i++) {
        cin >> C[i];
        for (ll j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    ll ans = L_INF;

    Vl score(M);
    for (ll mask = 0; mask < (1ll << N); mask++) {
        score.assign(M, 0);
        ll cost = 0;
        for (ll i = 0; i < N; i++) {
            if (mask >> i & 1) {
                for (ll j = 0; j < M; j++) {
                    score[j] += A[i][j];
                }
                cost += C[i];
            }
        }
        bool ok = true;
        for (ll j = 0; j < M; j++) {
            if (score[j] < X) {
                ok = false;
                break;
            }
        }

        if (ok) {
            ans = min(ans, cost);
        }
    }

    if (ans == L_INF) {
        ans = -1;
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3668
# include "iostream"
# include "cstdio"
# define Lowbit(x) ((x)&(-(x)))

using namespace std;

int N,S,T;

bool Check(int Now){
	register int Result=0;
	while(Now){
		Result++;
		Now-=Lowbit(Now);
	}
	return Result&1;
}

void Dfs(int A,int B,int Rest){
	if(A==B){
		printf("%d ",A);
		return;
	}
	int lowbit=Lowbit(A^B);
	Rest-=lowbit;
	int Last=Lowbit(Rest);
	Dfs(A,A^Last,Rest);
	Dfs(A^Last^lowbit,B,Rest);
	return;
}

int main(){
	scanf("%d%d%d",&N,&S,&T);
	if(Check(S^T)){
		printf("YES\n");
		Dfs(S,T,(1<<N)-1);
	}else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}
 
int main() {
    FAST_IO();
    int K, X; cin >> K >> X;
    repp(i, X - K + 1, X + K - 1) cout << i << " ";
    cout << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll a, b;
  cin >> a >> b;
  ll ans = (a + b < 24) ? a + b : a + b - 24;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
class SmallLargeOrEqual
	def result(a, b)
		result_val = b - a
		if result_val > 0
			puts "a < b"
		elsif result_val < 0
			puts "a > b"
		else
			puts "a == b"
		end
	end
end

INPUT_LIMIT = 2
input = gets.split.map(&:to_i)

if input.length == INPUT_LIMIT
	SmallLargeOrEqual.new.result(input[0], input[1])
else
	puts "You must input only two parameter"	
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int arr[3002];
ll dp[3003][3003],n;
ll finds(int st=0,int en=n-1)
{
    if(st>en)
        return 0;
    if(dp[st][en]!=-1)
        return dp[st][en];
    ll ans1=arr[st]+min(finds(st+2,en),finds(st+1,en-1));
    ll ans2=arr[en]+min(finds(st+1,en-1),finds(st,en-2));

    return dp[st][en]=max(ans1,ans2);

}

int main()
{
    ll i,j,s=0;
    cin>>n;
    memset(dp,-1,sizeof dp);
    for(i=0;i<n;i++)
        {
            cin>>arr[i];
            s+=arr[i];
        }
    ll y=finds();
    ll x=s-y;
    cout<<y-x<<endl;


}


Measured memory_bytes: 70912
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0 ; i < n ; i++) cin >> a[i];
    bool b = 1;
    int c = 0;
    while (b) {
    	for (int i = 0 ; i < n ; i++) if (a[i] % 2 == 1) b = 0;
		if (b) {
			for (int i = 0 ; i < n ; i++) a[i] /= 2;
			c++;
		}
	}
    cout << c;
}

Measured memory_bytes: 3556
/*{{{*/
#include <bits/stdc++.h>
#ifdef _GLIBCXX_DEBUG
int c_;
#define cout (c_?cerr:cout)
#define dbg(...) {if(!c_)cerr<<"\033[96;1m"; \
++c_; __VA_ARGS__; --c_; \
if (!c_)cerr<<<"\033[0m";}
#else
#define dbg(...)
#endif
#define st first
#define nd second
#define dprt(...) dbg(prt(__VA_ARGS__))
#define dmp(...) dprt(#__VA_ARGS__, __VA_ARGS__)
#define drprt(...) dbg(rprt(__VA_ARGS__))
#define rdmp(...) dbg(cerr<<#__VA_ARGS__<<": ";drprt(__VA_ARGS__))
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using ll = long long; using namespace std;
template< typename... t > using V = vector< t... >;
template< typename t > void prt(const t& a){cout<<a<<'\n';}
template< typename t, typename... v > void prt(const t& a, v&&... b)
{cout << a << ' '; prt(b...);}
template< typename t > void rprt(t a, const t& b)
{while(a!=b)cout<<(*a++)<<' ';cout << '\n';}
/*}}}*/

constexpr int maxn = 1e5;

int n, x;
int rs[maxn * 2];
bool vis[maxn * 2];

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

    cin >> n >> x;

    if (x == 2 * n - 1 or x == 1)
        return prt("No"), 0;

    prt("Yes");

    if (x == 2)
    {
        rs[n - 1] = 2, vis[2] = true;
        rs[n] = 1, vis[1] = true;
        rs[n - 2] = 3, vis[3] = true;
        if (n > 2)
            rs[n + 1] = 4, vis[4] = true;
    }
    else
    {
        rs[n - 1] = x, vis[x] = true;
        rs[n] = x + 1, vis[x + 1] = true;
        rs[n - 2] = x - 1, vis[x - 1] = true;
        rs[n + 1] = x - 2, vis[x - 2] = true;
    }

    int pt = 1;
    for (int i = 0; i < 2 * n - 1; ++i)
    {
        while (vis[pt]) ++pt;
        if (not rs[i]) rs[i] = pt++;
    }

    for (int i = 0; i < 2 * n - 1; ++i)
        prt(rs[i]);
        
        
}

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

#define INF INT_MAX
#define ll long long

using namespace std;

int main(){
	ll n,a;
	cin >> n;
	ll ans = 0;
	for(int i = 0;i < n;i++){
		cin >> a;
		ans += a % 2 != 0 ? 1 : 0;
	}
	if(ans % 2 == 0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
using namespace std;
int main(){
	int a[26]={0};
	int flag=0;
	string s;
	cin>>s;
	REP(i,0,s.length()-1){
		a[s[i]-'a']++;
	}
	REP(i,0,25){
		if(a[i]==0){
			flag=1;
			cout<<(char)(i+97);
			break;
			
		}
	}
	if(flag==0)
		cout<<"None";
		
	return 0;
}

Measured memory_bytes: 512
N = int(input())
C = list(map(int, input().split()))
C = reversed(sorted(C))

MOD = 10 ** 9 + 7
pow = 4 ** (N - 1) % MOD

ans = 0
for i, c in zip(range(N), C):
    ans += (i + 2) * c % MOD
    ans %= MOD

print(ans * pow % MOD)

Measured memory_bytes: 26800
# -*- coding: utf-8 -*-

#https://severrabaen.hatenablog.com/entry/2019/02/03/224150

n, m = map(int,input().split())
x = list(map(int,input().split()))

x.sort()

aida = [0] * (m-1)
for i in range(1,m):
    aida[i-1] = x[i] - x[i-1]

aida.sort()
aida.reverse()

del aida[:n-1]

print(sum(aida))


Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> v;
  FOR(i,2,55556){
    bool flag = 1;
    FOR(j,2,300)if(!(i%j))flag = 0;
    if(flag && i%5 == 1)v.push_back(i);
    if(v.size() == N)break;
  }
  for(auto x:v)cout << x << " ";cout << endl;
}


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

using ll = long long;

int main(){
    int sum=0;
    int x;
    for(int i=0;i<3;i++){
        cin>>x;
        sum+=x;
    }
    if(sum>=22)
    cout<<"bust";
    else
    cout<<"win";
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define INF 1e9
#define fs first
#define sc second
typedef unsigned long long ull;
typedef long long ll;


int main(){
	ll n,h,w,cnt = 0;
	cin >> n >> h >> w;
	ll a[n],b[n];
	
	rep(i,0,n) cin >> a[i] >> b[i];
	
	rep(i,0,n){
		if(a[i] >= h && b[i] >= w) cnt++;
	}
	
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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 namespace std;

int main(){
  ll N;
  cin>>N;
  ll A[N+1];
  REP(i,N+1) A[i]=0;
  
  for(int i=2; i<=N; ++i){
    ll a;
    cin>>a;
    A[a]++;
  }
  
  for(int i=1; i<=N; ++i) cout<<A[i]<<endl;
}

Measured memory_bytes: 5196
Q,H,S,D=map(int,input().split())
N=int(input())
litre=min(4*Q,2*H,S)
Litre=min(2*litre,D)
if N%2==0:
  print(Litre*(N//2))
else:
  print(Litre*(N//2)+litre)

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

const int MAP = 10005;
const int MMP = 10005;
const ll INF = 1001001001;

//モンスターの体力をi個の技でj減らすために必要な魔力の最小値をDPで
ll dp[MAP][MMP];

int main(void){
    int h,n;
    cin >> h >> n;
    vector<int> ap(MAP),mp(MMP);
    for(int i=0;i<n;i++) cin >> ap[i] >> mp[i];


    for(int i=0;i<MAP;i++) for(int j=0;j<MMP;j++) dp[i][j] = INF;
    dp[0][0] = 0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<MMP;j++){
            int nj = max(0, j-ap[i-1]);
            dp[i][j] = min(dp[i][j], dp[i][nj]+mp[i-1]);
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
        }
    }

    /*
    for(int i=0;i<=n;i++){
        for(int j=0;j<10;j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */

    cout << dp[n][h] << endl;

}

Measured memory_bytes: 782336
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

typedef long long ll;
const int N = 1e5 + 5;
int a[N];
int n;

int solve() {
    if (n == 1 || n == 2) return 1;
    int d = a[2] > a[1] ? 1 : 0;
    int ret = 0;
    for (int i=3; i<=n; ++i) {
//        if (a[i] == a[i-1]) continue;
        if (d != (a[i] > a[i-1])) {
            ret++;
            if (i == n) break;
            d = a[i+1] > a[i] ? 1 : 0;
        }
    }
    ret++;
    return ret;
}

int main() {
    scanf("%d", &n);
    int m = 0;
    for (int i=1; i<=n; ++i) {
        ++m;
        scanf("%d", &a[m]);
        if (m > 1 && a[m] == a[m-1]) m--;
    }
    n = m;
    printf("%d\n", solve());
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int N;
    cin >> N;
    vector<ll> L(N+1);
    L[0] = 2;
    L[1] = 1;
    FOR(i, 2, N + 1) {
        L[i] = L[i - 1] + L[i - 2];
   }
    cout << L[N] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 55;

bool mat1[N][N];
bool mat2[N][N];

int main ()
{
	int n, m;
	cin >> n >> m;
	for (int i =0 ; i < n ; i ++) {
		for (int j =0 ; j < n; j ++) {
			char x;
			cin >>x;
			mat1[i][j] = (x == '#');
		}
	}
	for (int i =0 ; i < m; i ++) {
		for (int j =0 ; j < m; j ++) {
			char x;
			cin >>x;
			mat2[i][j] = (x == '#');
		}
	}
	
	for (int i = 0; i < n-m+1; i++) {
		for (int j = 0; j < n-m+1; j++) {
			
				for (int ii = 0; ii < m; ii++) {
					for (int jj = 0; jj < m; jj++) {
						if (mat1[i+ii][j+jj] != mat2[ii][jj]) {
							goto heck;
						}
					}
				}
				cout << "Yes\n";
				return 0;
				
				heck:
				continue;
		}
	}
	
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _20180305_AOJ
{
    class ALDS1_5B
    {
        static int count;
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                count = 0;
                int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                MergeSort(A, 0, A.Length);

                for (int i = 0; i < A.Length - 1; i++)
                {
                    Console.Write(string.Format("{0} ", A[i]));
                }
                Console.WriteLine(A[A.Length - 1]);
                Console.WriteLine(count);
            }
        }

        static void Merge(int[] A, int left, int mid, int right)
        {
            int n1 = mid - left;
            int n2 = right - mid;
            int[] L = new int[n1 + 1];
            int[] R = new int[n2 + 1];
            int i = 0;
            for (i = 0; i < n1; i++)
            {
                L[i] = A[left + i];
            }
            for (i = 0; i < n2; i++)
            {
                R[i] = A[mid + i];
            }
            L[n1] = int.MaxValue;
            R[n2] = int.MaxValue;

            i = 0;
            int j = 0;
            for (int k = left; k < right; k++)
            {
                if (L[i] <= R[j])
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }

                count++;
            }
        }

        static void MergeSort(int[] A, int left, int right)
        {
            if (left + 1 < right)
            {
                int mid = (left + right) / 2;
                MergeSort(A, left, mid);
                MergeSort(A, mid, right);
                Merge(A, left, mid, right);
            }
        }
    }
}



Measured memory_bytes: 87328
Var a:Array[1 .. 1000] of Longint;
    count,n,i,m,p,x:Longint;
Begin
    Readln(n);
    For i:=1 to n do begin
        Read(a[i]);
        count:=count+a[i];
    End;
    Readln(m);
    For i:=1 to m do begin
        Readln(p,x);
        Writeln(count+(x-a[p]));
    End;
End.

Measured memory_bytes: 128
N=input()
keta=len(N)
K=int(input())

dp=[[[0 for i in range(K+1)] for j in range(2)] for k in range(keta)]

def getMiman(X):
  if X>0:
    return X-1
  else:
    return 0

x0=int(N[0])
dp[0][0][0]=0
dp[0][1][0]=1
dp[0][0][1]=1
dp[0][1][1]=getMiman(x0)

for i in range(1,keta):
  x=int(N[i])
  dp[i][0][0]=0
  dp[i][1][0]=1
  for j in range(1,K+1):
    dp[i][0][j]=dp[i-1][0][j-1]*(x!=0)+dp[i-1][0][j]*(x==0)
    dp[i][1][j]=dp[i-1][0][j-1]*getMiman(x)+dp[i-1][0][j]*(x!=0)+dp[i-1][1][j-1]*9+dp[i-1][1][j]*1
  
print(dp[keta-1][0][K]+dp[keta-1][1][K])  


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

int a, b, c;
bool v[105];
int main()
{
	int i, t;
	cin >> a >> b >> c;
	for (i = a; ; i += a) {
		t = i % b;
		if (t == c) {puts("YES"); return 0;}
		if (v[t]) {puts("NO"); return 0;}
		v[t] = 1;
	}
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll N = 1e6 + 10, MOD = 1e9 + 7;
ll inv[N], fac[N], inv_fac[N];

ll exp_mod(ll a, ll n) {
	ll res = 1;
	for (; n; n /= 2) {
		if (n&1) res = res*a % MOD;
		a = a*a % MOD;
	}
	return res;
}

ll inv_mod(ll a) {
	return exp_mod(a,MOD-2);
}

void precalc() {
	inv[1] = 1;
	FOR(n,2,N) inv[n] = -(MOD/n)*inv[MOD%n] % MOD;

	fac[0] = 1;
	FOR(n,1,N) fac[n] = n*fac[n-1] % MOD;

	inv_fac[0] = 1;
	FOR(n,1,N) inv_fac[n] = inv[n]*inv_fac[n-1] % MOD;
}

ll binom(ll n, ll k) {
	if (k < 0 || k > n) return 0;
	ll res = fac[n] * inv_fac[k] % MOD * inv_fac[n-k] % MOD;
	if (res < 0) res += MOD;
	return res;
}

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

	ll n, a, b, c;
	cin >> n >> a >> b >> c;
	
	ll per_win = 100*inv_mod(100-c) % MOD;
	
	a = a * inv_mod(100-c) % MOD, b = b*inv_mod(100-c) % MOD;
	
	ll res = 0;
	FOR(dir,0,2) {
		FOR(k,0,n) {
			ll prob = binom(n-1+k,k);
			prob = prob * exp_mod(a,n) % MOD;
			prob = prob * exp_mod(b,k) % MOD;
			res = (res + (n+k)*prob) % MOD;
		}
		swap(a,b);
	}
	
	res = res * per_win % MOD;
	if (res < 0) res += MOD;
	cout << res << endl;

}



Measured memory_bytes: 23680
package main

import "fmt"

func abs(a int64) int64 {
	if a < 0 {
		a = -a
	}
	return a
}

func main() {
	var n, k int64
	fmt.Scan(&n, &k)

	n %= k
	d := abs(n - k)
	if n >= d {
		n = d
	}
	fmt.Println(n)
}


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

void solver(){
	//type your code here
	ll A , B;
	cin >> A >> B;
	ll ans = 0;
	switch(B%4){
		case(0):{
			ans = B;
			break;
		}
		case(1):{
			ans = 1;
			break;
		}
		case(2):{
			ans = B+1;
			break;
		}
		case(3):{
			break;
		}
	}	
	A--;
	switch(A%4){
		case(0):{
			ans ^= A;
			break;
		}
		case(1):{
			ans ^= 1;
			break;
		}
		case(2):{
			ans ^= A+1;
			break;
		}
		case(3):{
			break;
		}
	}	
	cout << ans << endl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int queries = 1;
	//(cin >> queries);
	for(int i = 0 ; i < queries ; ++i){
		solver();
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <numeric>

using namespace std;
int main (){
    long long a,b,c,d,tmp,r,x;
    cin >> a >> b;
    if(a<b){
        tmp=a;
        a=b;
        b=tmp;
    }
    c=a;
    d=b;
    x=a*b;
    r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }

    cout << x/b <<"\n";

}

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

int main() {
    int A,B;
    cin >> A >> B;
    int S = 0;

    if (A - B >= 2) {
        S = A + A - 1;
    }

    else if (-1 <= A - B && A - B <= 1) {
        S = A + B;
    }

    else {
        S = B + B - 1;
    }

    cout << S << endl;
}

Measured memory_bytes: 256