akhauriyash/Code-Regression huggingface dataset:
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    static double[][] e;
    static long[][] nodes;
    static long[] barriers;
    static boolean[] flags;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int xs = sc.nextInt();
        int ys = sc.nextInt();
        int xt = sc.nextInt();
        int yt = sc.nextInt();
        int n = sc.nextInt();
        e = new double[n + 2][n + 2];
        nodes = new long[n + 2][2];
        barriers = new long[n + 2];
        flags = new boolean[n + 2];
        nodes[0][0] = xs;
        nodes[0][1] = ys;
        nodes[1][0] = xt;
        nodes[1][1] = yt;
        for (int i = 0; i < n; i++) {
            nodes[i + 2][0] = sc.nextInt();
            nodes[i + 2][1] = sc.nextInt();
            barriers[i + 2] = sc.nextInt();
        }
        calc_edge();

        PriorityQueue<Path> queue = new PriorityQueue<>(Comparator.comparingDouble(p -> p.score));
        queue.add(new Path(0, 0));
        while(!flags[1]) {
            Path next = queue.poll();
            if(flags[next.current]) {
                continue;
            }
            flags[next.current] = true;
            if(next.current == 1) {
                System.out.println(next.score);
                return;
            }
            for (int i = 0; i < flags.length; i++) {
                if(!flags[i]) {
                    queue.add(new Path(next.score + e[next.current][i], i));
                }
            }
        }
    }

    static class Path {
        double score;
        int current;
        Path(double score, int current) {
            this.score = score;
            this.current = current;
        }
    }

    static void calc_edge() {
        for (int i = 0; i < barriers.length; i++) {
            for (int j = i; j < barriers.length; j++) {
                double tmp = Math.pow((nodes[i][0] - nodes[j][0]) * (nodes[i][0] - nodes[j][0]) + (nodes[i][1] - nodes[j][1]) * (nodes[i][1] - nodes[j][1]), 0.5);
                tmp = Math.max(0, tmp - barriers[i] - barriers[j]);
                e[i][j] = tmp;
                e[j][i] = tmp;
            }
        }
    }
}

Measured memory_bytes: 66892
#include <iostream>
#include <algorithm>

using namespace std;

int GCD (int a, int b) {
    while (1) {
        if (a < b) swap(a, b);
        if (b == 0) break;
        a = a % b;
    }
    return a;
}

int LCM (int a, int b) {
    return a / GCD(a, b) * b;
}

int main (void) {
    int a, b;
    while (1) {
        cin >> a;
        cin >> b;
        if (cin.eof()) break;
        cout << GCD(a, b) << ' ' << LCM(a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
def main():
    N, K = map(int, input().split())
    a = [0] + list(map(int, input().split()))
    cost = float('inf')
    for i in range(2**N):
        b = a.copy()
        costtmp = 0
        for j in range(N):
            if (i>>j) & 1:
                maxb = max(b[:j+1])
                if maxb >= a[j+1]:
                    costtmp += maxb + 1 - a[j+1]
                    b[j+1] = maxb + 1
        check = 0
        for k in range(1, N+1):
            maxbk = max(b[:k])
            if maxbk < b[k]:
                check += 1
        if check >= K:
            cost = min(cost, costtmp)
        
    print(cost)


if __name__ == "__main__":
    main()


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

public class Main {	

	private static void solve(){
		//Implement solution here.
		int N = ni();
		char[] S = next().toCharArray();
		int[][] map = new int[3][N];
		for(int i = N - 1; i >= 0; i--) {
			if(i < N - 1) for(int j = 0; j < 3; j++)map[j][i] = map[j][i + 1];
			if(S[i] == 'R') {
				map[0][i]++;
			} else if(S[i] == 'G') {
				map[1][i]++;
			} else {
				map[2][i]++;
			}			
		}
		long result = 0;
		for(int i = 0; i < N - 2; i++) {
			for(int j = i + 1; j < N - 1; j++) {
				if(S[i] == S[j]) {
					continue;
				} else {
					if((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R')){
						//j should be B
						result += map[2][j + 1];
						if(j + j - i < N && S[j + j - i] == 'B')result--;
					} else if((S[i] == 'R' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'R')){
						//j should be G
						result += map[1][j + 1];
						if(j + j - i < N && S[j + j - i] == 'G')result--;
					} else {
						//j should be R
						result += map[0][j + 1];
						if(j + j - i < N && S[j + j - i] == 'R')result--;
					}
				}
			}	
		}
		System.out.println(result);
	}

	//Find greatest common divisor
	static int gcd (int a, int b) {
		return b > 0 ? gcd(b, a%b) : a;
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 26204
/*
        ####   ####
     ###    ###    ###
   ###    Bravery    ###
  ###  Determination  ###
   ##  Perseverance   ##
    ##   Integrity   ##
     ##  Patience   ##
      ## Kindness  ##
        ##Justice##
         ##     ##
           ## ##
             #
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
typedef long long ll;
using namespace std;
int n;
ll dp[105][5][5][5];
int main(){
	cin>>n;
	for (int j1=1;j1<=4;j1++){
		for (int j2=1;j2<=4;j2++){
			for (int j3=1;j3<=4;j3++){
				if (j1==1 && j2==3 && j3==2 || j1==1 && j2==2 && j3==3 || j1==3 && j2==1 && j3==2) continue;
				dp[3][j1][j2][j3]=1;
			}
		}
	}
	for (int i=3;i<n;i++){
		for (int j1=1;j1<=4;j1++){
			for (int j2=1;j2<=4;j2++){
				for (int j3=1;j3<=4;j3++){
					for (int nw=1;nw<=4;nw++){
						if (j2==1 && j3==3 && nw==2 || j2==1 && j3==2 && nw==3 || j2==3 && j3==1 && nw==2 || j1==1 && j3==3 && nw==2 || j1==1 && j2==3 && nw==2){
							continue;
						}
						dp[i+1][j2][j3][nw]=(dp[i+1][j2][j3][nw]+dp[i][j1][j2][j3])%1000000007;
					}
				}
			}
		}
	}
	ll sum=0;
	for (int j1=1;j1<=4;j1++){
		for (int j2=1;j2<=4;j2++){
			for (int j3=1;j3<=4;j3++){
				sum=(sum+dp[n][j1][j2][j3])%1000000007;
			}
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;    

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    

int main() {    
    int a, b; 
    cin >> a >> b;
    if(a >= 13) {
        cout << b << endl;
    } else if(6 <=a && a <= 12) {
        cout << b / 2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
#define inf             1e18
#define mod             1000000007
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}void _p() {cout << "]\n";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=========================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r;








void sol()
{   
    cin>>n;
    in(a,n);
    x=0;
    for(auto c:a)x^=c;
    for(auto c:a)cout<<(x^c)<<" ";
    
    
    
    //cout<<  <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 4724
from itertools import accumulate


def solve(string):
    h, w, *s = string.split()
    h, w = map(int, [h, w])
    t = [[1 if __s == "#" else 0 for __s in _s] for _s in s]
    hi = [list(accumulate(_t)) for _t in t]
    vi = [list(accumulate(_t)) for _t in zip(*t)]
    hg = [list(map(len, _s.split("#"))) for _s in s]
    vg = [list(map(len, "".join(_s).split("#"))) for _s in zip(*s)]
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, hg[i][hi[i][j]] + vg[j][vi[j][i]])
    return str(ans - 1)
  
  
if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))

Measured memory_bytes: 232560
//DEEPANSHU RAWAT
//BTECH/10530/18
//INFORMATION TECHNOLOGY

/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
 */
/*************************************************************************************************************************/
#include<bits/stdc++.h>
#define ull unsigned long long
#define lld long long int
#define infi LLONG_MAX
#define ninfi LLONG_MIN
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define e endl
#define mod 1000000007
#define modd 20000
using namespace std ;
lld v[100005];
/**************************************************************************************************************************/

/**************************************************************************************************************************/
int main()
    {
        ios_base::sync_with_stdio(false);//FOR FAST INPUT OUTPUT METHOD
        cin.tie(NULL);
        cout.tie(NULL);
        
        lld n;
        cin>>n;
        lld ans=-1;
        lld i,count=0;
        for(i=0;i<n;i++)
        {
            cin>>v[i];

        }   
        for(i=1;i<n;i++)
        {
            if((v[i]-v[i-1])<=0){
                count++;
                ans=max(ans,count);
            }
            else
            {
                
                count=0;
            }
        }
        if(ans==-1)
        {
            cout<<0;
        }
        else
        {
            cout<<ans;
        }
        
}
       
/**************************************************************************************************************************/                            


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << ((s.size() + (s[0] == s.back())) % 2 ? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 512
/**Lucky Boy**/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 2005
#define maxm 1000006
#define pii pair <int,int>
#define Task ""
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
using namespace std;
int n,m,dd[maxn][maxn],top,bot = 1;
pii s[maxn * maxn];
int xx[] = {0,0,1,-1};
int yy[] = {1,-1,0,0};
int main()
{
    ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
    //freopen(Task".inp", "r",stdin);
    //freopens(Task".out", "w",stdout);
    cin >> n >> m;
    memset(dd,-1,sizeof dd);
    FOR(i,1,n)
    {
        FOR(j,1,m)
        {
            char c;
            cin >> c;
            if (c == '#')
            {
                dd[i][j] = 0;
                s[++top] = {i,j};
            }
        }
    }
    while (bot <= top)
    {
        int u = s[bot].F,
            v = s[bot].S;
        ++bot;
        FOR(i,0,3)
        {
            int x = u + xx[i],
                y = v + yy[i];
            if (x < 1 || y < 1 || x > n || y > m || dd[x][y] != -1) continue;
            dd[x][y] = dd[u][v] + 1;
            s[++top] = mp(x,y);
        }
    }
    int ans = 0;
    FOR(i,1,n) FOR(j,1,m) ans = max(ans,dd[i][j]);
    cout << ans;
    return 0;

}


Measured memory_bytes: 24832
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Main {
    static int[] a1;
    static int a2[];
    static  ArrayList<Integer>[] connect;
    static int N;
    public static void main(String[] arg){
        Scanner sc=new Scanner(System.in);
        N=sc.nextInt();

        connect=new ArrayList[N];
        for(int i=0;i<N;i++){
            connect[i]=new ArrayList<>();
        }
        for(int i=0;i<N-1;i++){
            int a=sc.nextInt()-1;
            int b=sc.nextInt()-1;
            connect[a].add(b);
            connect[b].add(a);
        }
        int length=maxDepth2(maxDepth(0));
        if(length%3==1){
            System.out.println("Second");

        }else{

            System.out.println("First");
        }

    }
    static int maxDepth(int pos){
        Stack<Integer>stack=new Stack<>();
        int[] f=new int[N];
        int[] color=new int[N];
        int result1=pos;
        int result2=0;
        int dep=0;
        color[pos]=1;
        stack.push(pos);
        int now=pos;
        while(true){
            if(f[now]>=connect[now].size()){
                if(stack.empty()){
                    break;
                }
                now=stack.pop();
                dep--;
                continue;
            }
            int next=connect[now].get(f[now]);
            f[now]++;
            if(color[next]==0){
                color[next]=1;
                dep++;
                if(result2<dep){
                    result2=dep;
                    result1=next;
                }
                stack.push(now);
                now=next;
                continue;
            }
            if(dep==0){
                break;
            }
        }
        return result1;
    }
    static int maxDepth2(int pos){
        Stack<Integer>stack=new Stack<>();
        int[] f=new int[N];
        int[] color=new int[N];
        int result1=pos;
        int result2=0;
        int dep=0;
        color[pos]=1;
        stack.push(pos);
        int now=pos;
        while(true){
            if(f[now]>=connect[now].size()){
                if(stack.empty()){
                    break;
                }
                now=stack.pop();
                dep--;
                continue;
            }
            int next=connect[now].get(f[now]);
            f[now]++;
            if(color[next]==0){
                color[next]=1;
                dep++;
                if(result2<dep){
                    result2=dep;
                    result1=next;
                }
                stack.push(now);
                now=next;
                continue;
            }
            if(dep==0){
                break;
            }
        }
        return result2;
    }
}


Measured memory_bytes: 145460
#include <cstdio>
#include <algorithm>
#include <cstring>

struct query {
	int l, r, ind;
	bool operator<(const query &ob) {
		return l < ob.l;
	}
};

const int N = 500000;
int n, q, a[N], ans[N], last[N], s[N];
query qry[N];

void update(int i, int d) 
{
	while (i < n) {
		s[i] += d;
		i |= i + 1;
	}
}
int sum(int i) 
{
	int sm = 0;
	while (i >= 0) {
		sm += s[i];
		i = (i & (i + 1)) - 1;
	}
	return sm;
}

int main() 
{
	scanf("%d%d", &n, &q);
	for (int i = 0; i < n; ++i) {
		scanf("%d", a + i);
		--a[i];
	}
	for (int i = 0; i < q; ++i) {
		scanf("%d%d", &qry[i].l, &qry[i].r);
		--qry[i].l;
		--qry[i].r;
		qry[i].ind = i;
	}
	std::sort(qry, qry + q);
	memset(last, -1, 4 * n);
	for (int i = n - 1, j = q - 1; i >= 0; --i) {
		if (last[a[i]] != -1) update(last[a[i]], -1);
		update(i, 1);
		last[a[i]] = i;
		while (j >= 0 && qry[j].l > i) --j;
		while (j >= 0 && qry[j].l == i) {
			ans[qry[j].ind] = sum(qry[j].r);
			--j;
		}
	}
	for (int i = 0; i < q; ++i) printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 17268
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
  char c;
  cin >> c;

  switch (c) {
  case 'a':
  case 'e':
  case 'i':
  case 'o':
  case 'u':
    cout << "vowel\n";
    break;
  default:
    cout << "consonant\n";
    break;
  }

  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 256
def inpl(): return list(map(int, input().split()))
N = int(input())
ans = [0 for i in range(N-1)]
CSF = [inpl() for i in range(N-1)]

for i in range(N):
    t = 0
    for j in range(i, N-1):
        if t<CSF[j][1]:
            t = CSF[j][1]
        elif t%CSF[j][2]==0:
            pass
        else:
            t = t+CSF[j][2]-t%CSF[j][2]
        t += CSF[j][0]
    print(t)         

Measured memory_bytes: 3572
import heapq

N, D, A = map(int, input().split(" "))
proc_que = []

for _ in range(N):
    x, h = map(int, input().split(" "))
    heapq.heappush(proc_que, (x, h))

damaged = 0
ans = 0

while len(proc_que) > 0:
    x, h = heapq.heappop(proc_que)
    if h > 0:
        # monster
        num_bomb_use = max(0, (h - damaged + A - 1) // A)
        ans += num_bomb_use
        damaged += num_bomb_use * A
        heapq.heappush(proc_que, (x + 2 * D + 1, -num_bomb_use * A))
    else:
        # damaged end
        damaged += h

print(ans)

Measured memory_bytes: 87000
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,s=0,j,a[100];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {
            s+=(a[i]*a[j]);
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	long long n, a, b;
	long long dis[100000];
	cin >> n >> a >> b;
	for (long long i = 0; i < n; i++)cin >> dis[i];
	long long ans = 0;
	for (long long i = 0; i < n - 1; i++) {
		if ((dis[i + 1] - dis[i]) * a > b)ans += b;
		else ans += ((dis[i + 1] - dis[i]) * a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  string s, ans;
  vector<string> t = {"Sunny", "Cloudy", "Rainy"};
  cin >> s;
  if (s == t[0]) {
    ans = t[1];
  } else if (s == t[1]) {
    ans = t[2];
  } else {
    ans = t[0];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>

using ull = unsigned long long int;
using ll = long long int; 

ull gcd(ull a, ull b) {
  while(1) {
    if(a < b) std::swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main(){
    ull A,B,C,D;

    std::cin >> A >> B >> C >> D;

    ull cnt=B-A+1;

    cnt -= (B/C - (A-1)/C);
    cnt -= (B/D - (A-1)/D);
    cnt += (B/(C/gcd(C,D)*D) - (A-1)/(C/gcd(C,D)*D));

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())
setA = set([i for i in range(A,min(A+K,B+1))])
setB = set([i for i in range(max(A,B-K+1),B+1)])
setAB = sorted(setA | setB)
for i in list(setAB):
    print(i)

Measured memory_bytes: 3060
import numpy as np

N, D = map(int, input().split())

X = np.array([list(map(int, input().split())) for i in range(N)])

ans = 0
for n in range(N):
    for i in range(n+1, N):
        if np.linalg.norm(X[n]-X[i]).is_integer():
            ans += 1

print(ans) 

Measured memory_bytes: 12500
import bisect
N = int(input())
if len(str(N)) == 1:
    print(N)
    exit()
L = len(list(str(N)))-1
A = [10**(L)*i+10**(L)-1 for i in range(10)]  
n = bisect.bisect_left(A,N)-1
if N in A:
    n += 1
ans = [int(list(str(A[n]))[i]) for i in range(len(list(str(A[n]))))]
print(sum(ans))


Measured memory_bytes: 3064
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int r = 1;
  while (r*2 <= n) r*=2;
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    string s; cin>>s;
    int cnt[2]={};
    for(char c:s){
        if(c=='o') cnt[0]++;
        else cnt[1]++;
    }
    if(cnt[1]>=8) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    AB = []
    for _ in range(N):
        a, b = LI()
        AB.append([b, a])
    AB.sort()
    ans = True
    time = 0
    for b, a in AB:
        time += a
        if time > b:
            ans = False
            break
    ans = YesNo(ans)
    return ans

print(main())

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  i64 h, w;
  cin >> h >> w;
  i64 ans = LINF;
  i64 area = h * w;

  rep(i, 0, 2) {
    for(i64 j = 1; j < h; ++j) {
      i64 a = j * w;
      i64 b = (h - j) / 2ll * w;
      i64 c = area - a - b;

      i64 Max = max({a, b, c});
      i64 Min = min({a, b, c});
      ans = min(ans, Max - Min);
    }

    for(i64 j = 0; j <= h; ++j) {
      i64 a = j * w;
      i64 b = w / 2ll * (h - j);
      i64 c = area - a - b;

      i64 Max = max({a, b, c});
      i64 Min = min({a, b, c});
      ans = min(ans, Max - Min);
    }
    swap(h, w);
  }
  cout << ans << endl;
}


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

int INF = 0x3F3F3F3F;

struct Node {
	int Min;
	bool is;
} Tree[maxn << 2];

Node merge(const Node &a, const Node &b) {
	Node ret;
	ret.Min = min(a.Min, b.Min);
	ret.is = false;
	return ret;
}

void Build(int u, int l, int r) {
	Tree[u].Min = 0, Tree[u].is = false;
	if(l == r) return ;
	int m = (l + r) >> 1;
	Build(u << 1, l, m);
	Build(u << 1 | 1, m + 1, r);
}

void Update(int u, int l, int r, int L, int R, int x) { // from L to R will be x to x + R - L
	Node &o = Tree[u];
	if(L <= l && r <= R) {
//		cerr << u << " " << l << " " << r << " " << L << " " << R << " " << x << endl;
		o.Min = x + l - L;
		o.is = true;
		return ;
	}
	int m = (l + r) >> 1;
	if(l < r && o.is) {
		Tree[u << 1].is = true, Tree[u << 1].Min = o.Min;
		Tree[u << 1 | 1].is = true, Tree[u << 1 | 1].Min = o.Min + (m + 1) - l;
	}
	if(L <= m) Update(u << 1, l, m, L, R, x);
	if(R > m) Update(u << 1 | 1, m + 1, r, L, R, x);
	o = merge(Tree[u << 1], Tree[u << 1 | 1]);
}

int Query(int u, int l, int r, int x) {
	if(l == r) return Tree[u].Min;
	else if(Tree[u].is) return Tree[u].Min + x - l;
	else {
		int m = (l + r) >> 1;
		if(x <= m) return Query(u << 1, l, m, x);
		else return Query(u << 1 | 1, m + 1, r, x);
	}
}

int A[maxn], B[maxn];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	Build(1, 1, m);
	for(int i = 1; i <= n; ++i) scanf("%d%d", A + i, B + i);
	for(int i = 1; i <= n; ++i) {
		int d, a;
		if(A[i] == 1) d = INF;
		else d = Query(1, 1, m, A[i] - 1);
		Update(1, 1, m, A[i], B[i], d + 1);
		a = Tree[1].Min;
		printf("%d\n", a >= INF ? -1 : a + i);
	}
	return 0;
}

Measured memory_bytes: 9424
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define MOD 1000000007
#define ll long long
 
int cmpfunc(const void *a, const void *b){
    return (*(int*)a - *(int*)b);
}
 
void swap(int *a, int *b);
 
int main(int argc, char **argv){
    int n,i;
    scanf("%d",&n);
    int a[n+1];
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    int j=0;
    int position=1;
    while(j<=n){
        j++;
        position = a[position];
        if(position==2){
            printf("%d\n",j);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}
 
void swap(int *a, int *b){
    int tmp=*a;
    *a = *b;
    *b = tmp;
}

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

int main() {
    int N, n;
    cin >> N;
    n = N;
    int Sn = 0;
    while(n != 0) {
        Sn += n % 10;
        n = n / 10;
    }
    if (N % Sn == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    # A = list(map(int, input().split()))

    q, r, = divmod(N - 1, K - 1)
    ans = q + int(r > 0)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include<string.h>

int main(void) {
	
	int n = 0;
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;
	char s[3];
	int i;
	//int nn;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",s);
		if(strcmp(s,"AC")==0){
			ac = ac + 1;
		}
		if(strcmp(s,"WA")==0){
			wa = wa + 1;
		}
		if(strcmp(s,"TLE")==0){
			tle = tle + 1;
		}
		if(strcmp(s,"RE")==0){
			re = re + 1;
		}
		
	}
	
	printf("AC x %d\n",ac);
	printf("WA x %d\n",wa);
	printf("TLE x %d\n",tle);
	printf("RE x %d\n",re);
	
	
	
	
	return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

using ll = long long;
const ll INF = 1e18 + 1;


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

    char ch;
    cin >> ch;

    if (ch - 'a' >= 0) {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }



}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    int A = ((n+a-1)/a)*b;
    int B = ((n+c-1)/c)*d;
    cout << min(A, B) << '\n';
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  char c;
  cin >> c;

  if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') cout << "vowel" << endl;
  else cout << "consonant" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    N, K = Scanner.map_int()
    A = Scanner.map_int()
    for i in range(K, N):
        if A[i - K] < A[i]:
            print('Yes')
        else:
            print('No')


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 33368
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
 
using namespace std;
 
int h;
int w;
vector<pair<int,int> > v;
vector<pair<int,int> > vv;
#define MOD 1000000007
long long int ppow(long long int i, long long int j) {
	long long int res = 1LL;
	while (j) {
		if ((j & 1LL)) {
			res *= i;
			if (res >= MOD) {
				res %= MOD;
			}
		}
		j >>= 1;
		i *= i;
		if (i >= MOD) {
			i %= MOD;
		}
	}
	return res;
}
long long int usee = 0;
vector<int> nt;
int FF;
long long int k[1000002];
long long int choose(long long int beg, long long int num) {
	if (beg < num)return 0;
	long long int u = k[beg];
	long long int d = ppow(k[beg-num], MOD - 2);
	u *= d;
	return u % MOD;
}
set<int> valid;
long long int way(long long int can, long long int lim,bool flag=false) {
	if (can == 0LL)return 0;
	while (FF < nt.size() && nt[FF] <= lim)FF++;
	int ava = FF - usee;
	if (ava < can) {
		puts("0");
		exit(0);
	}
	long long int u = choose(ava, can);// ppow(ava, can);
	long long int d = choose(ava - 1, can);// ppow(ava - 1, can);
	if (valid.count(lim)) {
		//cout << lim << endl;
		u += MOD - d;
		u %= MOD;
	}
	usee += can;
	return u;
}
map<int, int> mx;
map<int, int> my;
 
map<int, int> X;
map<int, int> Y;
 
bool used[1002][1002];
 
int main() {
	cin >> h >> w;
	k[0] = 1;
	for (int i = 1; i <= 1000001; i++) {
		k[i] = k[i - 1] * i;
		k[i] %= MOD;
	}
	for (int i = 0; i < h; i++) {
		int a;
		scanf("%d", &a);
		v.push_back(make_pair(a,i) );
		mx[a]++;
		X[a] = i;
	}
	for (int i = 0; i < w; i++) {
		int a;
		scanf("%d", &a);
		vv.push_back(make_pair(a,i) );
		my[a]++;
		Y[a] = i;
	}
	for (int i = 1; i <= h * w; i++) {
		if (mx[i] > 1 || my[i] > 1) {
			puts("0");
			return 0;
		}
		if (mx[i] == 1 && my[i] == 1) {
			used[X[i]][Y[i]] = true;
			continue;
		}
		nt.push_back(i);
		valid.insert(i);
	}
	sort(v.begin(), v.end());
	sort(vv.begin(), vv.end());
	int i = 0;
	int j = 0;
	long long int ans = 1;
	while (i < v.size() || j < vv.size()) {
		if (j == vv.size() || (i != v.size() && v[i] < vv[j])) {
			long long int lim = v[i].first;
			int can = 0;
			for (int j = 0; j < w; j++) {
				if (used[v[i].second][j] == false) {
					used[v[i].second][j] = true;
					can++;
				}
			}
			if (can == 0 && valid.count(v[i].first) == 0) {
				i++;
				continue;
			}
			ans *= way(can,lim);
			i++;
			ans %= MOD;
		}
		else {
			long long int lim = vv[j].first;
			int can = 0;
			for (int i = 0; i < h; i++) {
				if (used[i][vv[j].second] == false) {
					used[i][vv[j].second] = true;
					can++;
				}
			}
			if (can == 0 && valid.count(vv[j].first) == 0) {
				j++;
				continue;
			}
			ans *= way(can, lim);
			j++;
			ans %= MOD;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 153836
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, K = list(map(int, sys.stdin.readline().split()))
H = list(map(int, sys.stdin.readline().split()))

if K == N:
    print(0)
    exit()

# H = np.array(H, dtype=float)

# # @debug
# def count(heights, changes):
#     H = heights.copy()
#     H = H[~changes]
#     ret = 0
#     cnt = 1
#     height = H.min()
#     # 普通に数えてみる
#     while height != np.inf:
#         H -= height
#         ret += cnt * height
#         H[H == 0.0] = np.inf
#         cnt = np.count_nonzero(np.diff((H != np.inf).astype(int)) == 1)
#         cnt += H[0] != np.inf
#         height = H.min()
#     return int(ret)
#
#
# # 上から何個変えるか、下から何個変えるかを全探索
# ans = INF
# orders = H.argsort()
# for _ in range(K + 1):
#     # 変えるやつ
#     changes = np.zeros(N, dtype=bool)
#     changes[orders[:K]] = True
#     ans = min(ans, count(H, changes))
#     orders = np.roll(orders, shift=1)
# print(ans)


# dp[i][k][h]: i まで見た、k 個無視した、今の高さが h であるときの塗る数
dp = [[defaultdict(lambda: INF) for _ in range(K + 2)] for _ in range(N + 1)]
dp[0][0][0] = 0
for i in range(N):
    for k in range(K + 1):
        for h, cnt in dp[i][k].items():
            dp[i + 1][k][H[i]] = min(dp[i + 1][k][H[i]], cnt + max(0, H[i] - h))
            dp[i + 1][k + 1][h] = min(dp[i + 1][k + 1][h], dp[i][k][h])
ans = min(dp[-1][K].values())
print(int(ans))


Measured memory_bytes: 368520
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    while(true){
        int n, x;
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        int count = 0;
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                for(int k=0; k<n; k++){
                    if(i<j && j<k){
                        if(i+j+k+3 == x) count += 1;
                    }
                }
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3076
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R; cin >> R;
    if( R < 1200) cout << "ABC" << endl;
    else if (R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;

    return 0;
}


Measured memory_bytes: 256
#C
N,M,X = map(int,input().split())
C = []
A = []

for c in range(N):
	p = list(map(int,input().split()))
	C.append(p[0])
	A.append(p[1:])

minCost = sum(C)
exist = False

for i in range(2 ** N):
	rikai = [0] * M
	cost = 0
	for n in range(N):
		if i >> n & 1 == 0:
			cost+=C[n]
		
			for m in range(M):
				rikai[m]+=A[n][m]
	ok = True

	for m in range(M):
		if rikai[m] < X:
			ok = False

	if ok:
		exist = True
		minCost = min(minCost,cost)

if exist:
	print(minCost)
else:
	print(-1)


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

typedef long long LL;
const int N = 2e5 + 5;

int n;
LL ans = 9e18, d[N], x;

int main() {
	cin>>n>>x;
	for(int i = 1; i <= n; i++) 
		cin>>d[i], d[i] += d[i - 1];
	for(int k = 1; k <= n; k++) {
		LL res = 0, j = 3;
		for(int i = n; i >= 1; i -= k) {
			res += (d[i] - d[max(0, i - k)])*max(5ll, j);
			j += 2;
			if(res >= ans) break;
		}
		ans = min(ans, res + k*x);
	}
	cout<<ans + n*x<<endl;
}

Measured memory_bytes: 1792
a,b,c,d,t;
main(n){
  while(~scanf("%d",&n)){
    t=0;
  for(a=0;a<=9;a++)
  for(b=0;b<=9;b++)
  for(c=0;c<=9;c++)
  for(d=0;d<=9;d++)
    if(a+b+c+d==n)
      t++;
  printf("%d\n",t);
}
  return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main(){
	int a,b,c,d,n;
	cin>>n>>a>>b>>c>>d;
	string s;
	cin>>s;
	a--;b--;c--;d--;

	bool flag=true;
	for (int i = a; i < d; i++){
		if(s[i] == '#' and s[i+1] == '#'){
			flag = false;	
		}
	}

	if(d<c){
		flag=false;
		for (int i = b-1; i < d; i++){
			if(s[i] == '.' and s[i+1] == '.' and s[i+2] == '.'){
				flag = true;
			}
		}
	}

	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}


	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++) 
#define S(v) sort(v.begin(),v.end());


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    while(b<=a){
        b *=2;
        k--;
    }
    while(c<=b){
        c*=2;
        k--;
    }
    cout<<(k>=0?"Yes":"No");
    

}

Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    //int n;
    //cin >> n;
    int a,b,c;
    cin >> a >> b;
    if (a >= 13) cout << b << endl;
    else if (a >= 6) cout << b /2 << endl;
    else cout << 0 << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


#define MAX 1000000


int isPrime[MAX];


int main(){
    int num;
    int i, j;
    int count;
    
    // 配列の初期化
    isPrime[0] = isPrime[1] = 0;
    for(i = 2; i < MAX; i++){
        isPrime[i] = 1;
    }
    
    // エラストテネスのふるい
    for(i = 2; i * i < MAX; i++){
        if(isPrime[i]){
            // iの倍数は素数じゃないのでフラグ変更
            for(j = 2 * i; j < MAX; j+=i){
                isPrime[j] = 0;
            }
        }
    }


    while(scanf("%d", &num) != EOF){
        count = 0;
        while(num){
            count += isPrime[num--];
        }
        printf("%d\n", count);
    }


    return 0;
}

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

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    ll N;
    cin >> N;
    vector<int> A;
    A.push_back(N/1000);
    N = N%1000;
    A.push_back(N/100);
    N = N%100;
    A.push_back(N/10);
    A.push_back(N%10);
    rep(i, 8){
        int ans=A.at(0);
        vector<char> pm;
        rep(k, 3){
            if(i & (1<<k)){
                ans += A.at(k+1);
                pm.push_back('+');
            }else{
                ans -= A.at(k+1);
                pm.push_back('-');
            }
        }
        if(ans==7){
            cout << A.at(0);
            rep(k,3){
                cout << pm.at(k);
                cout << A.at(k+1);
            }
            cout<<"=7"<<endl;
            return;
        }
    }
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 256
# 優先度キューを使う
import heapq

N, M = [int(x) for x in input().split()]
AB = [0] * N

for i in range(N):
    AB[i] = [int(x) for x in input().split()]

# 毎日、候補となる集合を再計算すると間に合わない
# M-1日後から当日に向けて計算してけば、
# day 日時点で day + a = M となる仕事だけを候補に追加することで
# day + 1日までに追加した候補を再利用できる。
# さらに、候補からpopした要素は次回から考慮しないため、設問の条件とも一致する。

# 仕事の候補、徐々に追加していく
candidates = []
# nextpush 次に候補としてpush するか判定するcandidates の添え字
nextpush = 0

# 期間の短いものから候補に入れていくので期間でソートしておく
# AB[i][0] が期間なので、キー指定不要

AB = sorted(AB)

# 回答
answer = 0

for day in range(M)[::-1]:
    while nextpush < N:
        a, b = AB[nextpush]
        if day + a == M:
            # 給料が高い順ものを優先して取り出したいので、-b をキューにいれる。
            heapq.heappush(candidates, -b)
            nextpush += 1
        else:
            # AB はソート済みなので、これ以降の要素に候補に追加できるものはない
            # 次回は nextpush から再開する。
            break
    if candidates: # 仕事が出来ない日もあるかも・・・
        b = heapq.heappop(candidates)
        # マイナスで入れてるので、符号を逆にして戻す
        answer -= b

print(answer)


Measured memory_bytes: 25692