akhauriyash/Code-Regression huggingface dataset:
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 105;

int N, W;
Pii A[MAXN];

void input()
{
    read(N); read(W);
    for (int i = 1; i <= N; ++i) {
        read(A[i].x); read(A[i].y);
    }
}

void solve()
{
    int base = A[1].x;
    for (int i = 1; i <= N; ++i) {
        A[i].x -= base;
    }

    static int dp[MAXN][MAXN*3];

    memset(dp, -oo, sizeof(dp));
    dp[0][0] = 0;
    for (int i = 1; i <= N; ++i) {
        for (int j = i; j >= 1; --j) {
            for (int k = 3 * N; k >= A[i].x; --k) {
                chkmax(dp[j][k], dp[j-1][k-A[i].x] + A[i].y);
            }
        }
    }

    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j <= 3 * N && (LL)i * base + j <= W; ++j) {
            chkmax(ans, dp[i][j]);
        }
    }
    printf("%d\n", ans);
}

int main()
{
#ifdef __DEBUG
    freopen("D.in", "r", stdin);
    freopen("D.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 位卑未敢忘忧国，事定犹须待阖棺。
//     -- 陆游《病起书怀》


Measured memory_bytes: 384
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A = 256

def main(N, V, W, v, L):
    def precompute(N, V, W):
        U = 10**5 + 10
        dp = np.zeros((A, U), np.int32)
        for v in range(1, min(A, N + 1)):
            p = v // 2
            dp[v] = dp[p]
            dp[v, W[v]:] = np.maximum(dp[v, W[v]:], dp[p, :-W[v]] + V[v])
            for i in range(1, U):
                dp[v][i] = max(dp[v][i], dp[v][i - 1])
        return dp

    dp = precompute(N, V, W)
    values = np.empty((2**18)//A, np.int32)
    weights = np.empty((2**18)//A, np.int32)

    def solve(i, lim, values, weights, dp):
        if i < A:
            return dp[i][lim]
        values[0] = 0
        weights[0] = 0
        p = 0
        while i >= A:
            for j in range(1 << p):
                values[j + (1 << p)] = values[j] + V[i]
                weights[j + (1 << p)] = weights[j] + W[i]
            p += 1
            i >>= 1
        best = 0
        for n in range(1 << p):
            if weights[n] > lim:
                continue
            x = dp[i][lim - weights[n]] + values[n]
            best = max(best, x)
        return best

    Q = len(v)
    for i in range(Q):
        x = solve(v[i], L[i], values, weights, dp)
        print(x)

        
if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i4,i4[:],i4[:],i4[:],i4[:])')(main)
    cc.compile()
    exit()

from my_module import main

N = int(readline())
stdin = np.array(read().split(), np.int32)
V = np.zeros(N + 1, np.int32)
W = np.zeros(N + 1, np.int32)
V[1:] = stdin[:N + N:2]
W[1:] = stdin[1:N + N:2]
query = stdin[N + N + 1:]
v, L = query[::2].copy(), query[1::2].copy()

main(N, V, W, v, L)


Measured memory_bytes: 134732
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

long gcd(long m, long n) {
    if (m % n == 0) {
        return n;
    } else {
        return gcd(n, m % n);
    }
}

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

int main() {
    long ans;
    int i, j;
    cin >> i >> i >> j;
    ans = lcm(i, j);
    while (cin >> j) {
        ans = lcm(ans, j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc082.contest.atcoder.jp/tasks/arc082_b>
問題文============================================================
 1,2,..,N からなる順列 p1,p2,..,pN が与えられます。 次の操作を何回か (0回でもよい) 行うことが出来ます。
 
 操作: 順列で隣り合う二つの数を選んでスワップする。
 
 何回か操作を行って、任意の 1≤i≤N に対して pi≠i となるようにしたいです。 必要な操作の最小回数を求めてください。
 制約
 2≤N≤105
 p1,p2,..,pN は 1,2,..,N の順列である。
=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> p(N+1);
    for(int i = 1; i <= N;i++) cin >> p[i];
    ll cnt = 0;
    for(int i = 1; i <= N;i++){
        if(p[i] == i){
            if(i == N){
                swap(p[i-1],p[i]); cnt++;
                continue;
            }else{
                swap(p[i],p[i+1]); cnt++;
                continue;
            }
        }
    }
    cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
	static long GCD(long x, long y) {
		if(Math.max(x, y) % Math.min(x, y) == 0) return Math.min(x, y);
		return GCD(Math.min(x, y), Math.max(x, y) % Math.min(x, y));
	}
	static int GCD(int x, int y) {
		return (int)GCD((long)x, (long)y);
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long T = sc.nextLong(), A = sc.nextLong();
		for(int i = 1; i < N; i++) {
			long Ti = sc.nextLong(), Ai = sc.nextLong();
			if(Ti >= T && Ai >= A) {
				T = Ti; A = Ai;
				continue;
			}
			// Ti * k >= T となるk, Ai * k >= Aとなるkを求める
			long kT = T / Ti, kA = A / Ai;
			if(T % Ti != 0) kT++;
			if(A % Ai != 0) kA++;
			long k = Math.max(kT, kA);
			T = Ti * k; A = Ai * k;
		}
		System.out.println(T + A);
	}
}

Measured memory_bytes: 26224
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
int main(){
    
    int n,m;
    cin >> n;
    
    vector<string> s(n);
    rp(i,n){
        cin >> s.at(i);
    }
    
    cin >> m;
    
    vector<string> t(m);
    rp(i,m){
        cin >> t.at(i);
    }
    
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    
    int max=0;
    rp(i,n){
        int cnt=0;
        rp(j,n){
            if(s.at(i) == s.at(j)){
                cnt++;
            }
        }
        rp(j,m){
            if(s.at(i) == t.at(j)){
                cnt--;
            }
        }
    
        max = (max>cnt?max:cnt);
    }
    
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int d, t, s;
    cin >> d >> t >> s;
    string ans = "No";
    if (d<=t*s) ans = "Yes";
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int k,n; cin>>k>>n;
	VI a(n); rep(i,n)cin>>a[i];
	VI b(n);
	rep(i,n){
		if(i==0) b[i] = a[0]+k-a[n-1];
		else b[i] = a[i]-a[i-1];
	}
	sort(ALL(b));
	int ans = 0;
	rep(i,n-1){
		ans += b[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] hills = new int[n];
        for(int i = 0;i<n;i++) {
            hills[i] = in.nextInt();
        }
        int counter = 1;
        int cur = hills[0];
        for(int i = 1;i<n;i++) {
            if(hills[i]>=cur) {
                counter++;
                cur = hills[i];
            }
        }
        System.out.println(counter);
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,k,c;
const int Maxn=2e5+5;
char s[Maxn];
int b[Maxn],dp[Maxn];
int main(){
	scanf("%d%d%d%s",&n,&k,&c,s+1);
	memset(b,-1,sizeof(b));
	int i=1;
	for(int t=0;t<k;t++){
		while(s[i]=='x')i++;
		b[i]=t;
		i+=c+1;
	}
	for(int i=n;i>=1;i--){
		int add=(s[i]=='o');
		dp[i]=max(dp[i+1],add);
		if(i+c+1<=n){
			chkmax(dp[i],dp[i+c+1]+add);
		}
	}
//	for(int i=1;i<=n;i++)printf("%d ",b[i]);printf("\n");
//	for(int i=1;i<=n;i++)printf("%d ",dp[i]);printf("\n");
	for(int i=1;i<=n;i++){
		if(b[i]!=-1&&b[i]+dp[i+1]<k){
			printf("%d\n",i);
		}
	}
	return 0;
}

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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a, b;
	cin>>a>>b;
	if (a > b)
	{
		for (int i = 0; i < a; ++i)
		{
			cout<<b;
		}
		cout<<endl;
	}
	else if (a < b)
	{
		for (int j = 0; j < b; ++j)
		{
			cout<<a;
		}
		cout<<endl;
	}
	else
	{
		for (int k = 0;k < b; ++k)
		{
			cout<<a;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#define N 1001000
#define M 1001000
using namespace std;
int dis[N],nxt[M],to[M],w[M],head[N];
int n,m,s,t;
queue<int> q;
inline int read(){
	char ch;
	int f=1,res=0;
	while((ch=getchar())<'0'||ch>'9')
		if(ch=='-') f=-1;
	while(ch>='0'&&ch<='9')
	{
		res=(res<<1)+(res<<3)+(ch^48);
		ch=getchar();
	}
	return f*res;
}
int tot=0;
bool vis[N];
void add(int x,int y,int z){
	nxt[++tot]=head[x];
	head[x]=tot;
	w[tot]=z;
	to[tot]=y;
}

void spfa(int u){
	while (!q.empty()) q.pop();
	q.push(u);
	vis[u]=1;
	while(!q.empty()){
		int x=q.front();
		q.pop();
		vis[x]=0;
		for(int i=head[x];i;i=nxt[i]){
			int y=to[i];
			if(dis[x]+w[i]<dis[y]){
				dis[y]=dis[x]+w[i];
				if(!vis[y]) vis[y]=1,q.push(y);
			}
		}
	}
}

bool vis1[N];
queue<int> q1;
int dis1[N];

void spfa1(int u){
	q1.push(u);
	vis1[u]=1;
	while(!q1.empty()){
		int x=q1.front();
		q1.pop();
		vis1[x]=0;
		for(int i=head[x];i;i=nxt[i]){
			int y=to[i];
			if(dis1[x]+w[i]<dis1[y]){
				dis1[y]=dis1[x]+w[i];
				if(!vis1[y]) vis1[y]=1,q1.push(y);
			}
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	//memset(G,0,sizeof(G));
	cin >> n;
	m = n-1;
	//n=read();m=read();s=read();t=read();
	int i,j,k;
	for(i=1;i<=m;++i)
	{
		int x,y;
		cin >> x >>y;
		//x=read();y=read();
		add(x,y,1);
		add(y,x,1);
		//G[x][y] =1,G[y][x]=1;
		
	}	
	for(i=1;i<=n;++i)
	{
		// dis1[i]=2147483647;
		// vis1[i]=0;
		dis[i]=0x3f3f3f3f;
		vis[i]=0;
	}
	t=1;
	dis[t]=0;
	spfa(t);
	int x,maxx=-1;
	for (int i=1;i<=n;i++) if (dis[i]>maxx)maxx=dis[i],x=i;
	//cout << x<<"asa";
	for(i=1;i<=n;++i)
	{
		// dis1[i]=2147483647;
		// vis1[i]=0;
		dis[i]=0x3f3f3f3f;
		vis[i]=0;
	}
	dis[x]=0;
	spfa(x);
	// for(i=1;i<=n;++i)
	// 	printf("%d %d\n",dis[i],dis1[i]);
	maxx=-1;
	for (int i=1;i<=n;i++) if (dis[i]>maxx)maxx=dis[i],x=i;	
	maxx++;	
//	cout << maxx;
	cout << (maxx%3 == 2?"Second":"First");
	// int ans=0;
	// for (int i=1;i<=n;i++)
	// 	for (int j=i+1;j<=n;j++) if (!G[i][j]){
	// 		if (dis[i]+dis1[j]+1>=dis[t] && dis1[i]+dis[j]+1>=dis[t] ) ans++;//,cout << i << ' '<<j<<endl;
	// 	}
	// 	cout << ans;
	return 0;
}

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

n = K
ans = 0

if(K <= A):
    print(K)
elif(A < K <= A+B):
    print(A)
else:
    if((K-(A+B)) < C):
        ans = A+(K-A-B)*(-1)
        print(ans)
    else:
        ans = A+C*(-1)
        print(ans)

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

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

    for(int i=0;i<(1<<n);i++)
    {
        if(__builtin_popcount(i)!=k)continue;
        cout<<i<<":";
        
        for(int j=0;j<n;j++)
        {
            if((i>>j)&1)cout<<" "<<j;
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3092
S=input()
bef0=(1,S[0])
bef1=(2,S[1])
if bef0[1]==bef1[1]:
    print("1 2")
    exit()
else:
    flag=True
    for i in range(2,len(S)):
        if bef0[1]==S[i] or bef1[1]==S[i]:
            print(" ".join([str(bef0[0]),str(i+1)]))
            flag=False
            break
        else:
            bef0=bef1
            bef1=(i+1,S[i])
    if flag:
        print("-1 -1")

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
    int n;
    for(;;){
        cin>>n;
        if(n==0) break;
        int ds[]={1,2,3,5,4,6};
        int sum=ds[0];
        for(int i=0;i<n;i++){
            string s;
            cin>>s;
            if(s=="North"){
                int t=ds[0];
                ds[0]=ds[1];
                ds[1]=ds[5];
                ds[5]=ds[3];
                ds[3]=t;
            }else if(s=="South"){
                int t=ds[0];
                ds[0]=ds[3];
                ds[3]=ds[5];
                ds[5]=ds[1];
                ds[1]=t;
            }else if(s=="East"){
                int t=ds[0];
                ds[0]=ds[4];
                ds[4]=ds[5];
                ds[5]=ds[2];
                ds[2]=t;
            }else if(s=="West"){
                int t=ds[0];
                ds[0]=ds[2];
                ds[2]=ds[5];
                ds[5]=ds[4];
                ds[4]=t;
            }else if(s=="Right"){
                int t=ds[1];
                ds[1]=ds[2];
                ds[2]=ds[3];
                ds[3]=ds[4];
                ds[4]=t;
            }else if(s=="Left"){
                int t=ds[1];
                ds[1]=ds[4];
                ds[4]=ds[3];
                ds[3]=ds[2];
                ds[2]=t;
            }
            sum+=ds[0];
        }
        cout<<sum<<endl;
    }
}

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

int main() {
	string S, T;
	cin >> S >> T;
	char s[100], t[110];
	for (int i = 0; i < S.length(); i++) {
		s[i] = S[i];
	}
	for (int i = 0; i < T.length(); i++) {
		t[i] = T[i];
	}
	sort(s, s + S.length());
	sort(t, t + T.length(),greater<int>());
	S = s; T = t;
	if (S < T) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split(" "))
mod = 1000000007
aList = set([int(input()) for i in range(M)])
dp = [0] * (N+1)
dp[0] = 1


for i in range(1,N+1) :
    dp[i] = dp[i-1] + dp[i-2]
    if i in aList :
        dp[i] = 0
print(dp[N]%mod)

Measured memory_bytes: 460020
//
//#include<stdio.h>
//int main()
//{
//    int a;
//    char s[12];
//    scanf("%a%s",a,s);
//    if(a<3200)
//        printf("red");
//    else
//        printf("%s",s);
// return 0;
//}

#include<stdio.h>
int main()
{
    int a;
    char s[12];
    scanf("%d%s",&a,s);
    if(a<3200)
        printf("red");
    else
        printf("%s",s);
 return 0;
}


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

const ll MAX=1000000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  ll X,Y;
  cin>>X>>Y;
  if(X<Y/2 || Y<X/2){cout<<0<<endl;}
  else if((X+Y)%3!=0){cout<<0<<endl;}
  else{
      ll move=(X+Y)/3;//移動回数
      ll movex,movey;//(2,1)(1,2)それぞれの回数
      movex=X-move;
      movey=Y-move;

  COMinit();
  
  cout<<COM(move,movex)<<endl;
  }
}

Measured memory_bytes: 23680
import java.util.*;

public class Main{
	private static Scanner sc=new Scanner(System.in);
	
	public static void main(String[] args){
		int n=readInt();
		long a;
		long s[]=new long[n+1];
		for(int i=0;i<n;i++){
			a=readLong();
			if(i==0)s[i]=a;
			else s[i]=s[i-1]+a;
		}
		s[n]=0;
		HashMap<Long,Long> mp = new HashMap<Long,Long>();
		for(int i=0;i<n+1;i++){
			Long t=mp.get(s[i]);
			if(t==null)mp.put(s[i],(long)1);
			else mp.put(s[i],t+1);
		}
		long ans=0;
		for(Long x:mp.keySet()){
			long c=mp.get(x);
			ans+=c*(c-1)/2;
		}
		System.out.println(ans);
	}
	
	private static int readInt(){
		return Integer.parseInt(sc.next());
	}
	private static long readLong(){
		return Long.parseLong(sc.next());
	}
}


Measured memory_bytes: 58932
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , A , B;
  cin >> N;
  cin >> A;
  cin >> B;
  if ( ( N * A ) < ( B ) ){
    cout << ( N * A ) << endl;
  }
  else {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  int l=s.size();
  int A=0,Z=0;
  for(int i=0;i<l;i++){
    if(s[i]=='A'){
      A=i;
      break;
    }
  }
  for(int i=l-1;i>=0;i--){
    if(s[i]=='Z'){
      Z=i;
      break;
    }
  }
  cout<<Z-A+1<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a;
    cin >> n ;
    vector<int>v;
    for(int i=0; i<n; i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    int t = 0 ,b = 0;a=0;
    sort(v.begin(),v.end());
    for(int i=v.size()-1; i>=0; i--)
    {
        if(t==0)
        {
            a+= v[i];
           t = 1;
        }
        else
        {
            b += v[i];
            t = 0;
        }

    }
    cout << a-b << endl;

}


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

typedef long long lint;

int main(){
  lint n, m;
  cin >> n >> m;
  lint ans;
  if(n == 1 && m == 1){
    ans = 1;
  }else if(n == 1){
    ans = m - 2;
  }else if(m == 1){
    ans = n - 2;
  }else{
    ans = (n - 2) * (m - 2);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

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

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }

    map<ll, ll> mp;
    rep(i, N) { ++mp[A[i]]; }

    ll all = 0;

    map<ll, ll> sub;
    for (auto e : mp) {
        all += e.second * (e.second - 1) / 2;
        sub[e.first] = max(
            0ll, e.second - 1);
    }

    rep(i, N) { cout << all - sub[A[i]] << endl; }
}

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

int main(){
    long long n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;

    long long minv = a;
    minv = min(minv, b);
    minv = min(minv, c);
    minv = min(minv, d);
    minv = min(minv, e);

    
    long long team;

    if(n <= minv){
        printf("5\n");
    }
    else{
        team = (n+ minv -1 )/minv;
        printf("%lld\n", 4 + team);
    }
    

    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

int main(){
    int n;
    cin >> n;
    if(n == 1) cout << "Hello World";
    else{
        int a,b;
        cin >> a >> b;
        cout << (a+b);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 800005
typedef pair<int,int> P;

enum Type{
	TATE,
	YOKO,
};

struct Line{

	int x1,y1,x2,y2;
};

int N;
vector<int> X,Y;
set<int> table[2][SIZE];
set<P> SET[2][SIZE];
map<int,int> map_X,map_Y;
Type rev[2] = {YOKO,TATE};
Line line[SIZE];

//簡易化のため、要素数を2のべき乗にする関数
void init(int first_N){
	while(N < first_N)N *= 2;
}

void add(int left,int right,int value,int node_id,int node_left,int node_right,Type type){

	if(right < node_left || left > node_right)return;
	else if(left <= node_left && right >= node_right){

		table[type][node_id].insert(value);

	}else{
		add(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2,type);
		add(left,right,value,2*node_id+2,(node_left+node_right)/2+1,node_right,type);
	}
}

bool isCross(int loc,int mini,int maxi,Type type){

	loc += N-1;

	while(true){

		if(table[type][loc].lower_bound(mini) != table[type][loc].upper_bound(maxi)){

			return true;
		}
		if(loc == 0){

			return false;
		}
		loc = (loc-1)/2;
	}
	return false;
}


int main(){

	int first_N;
	scanf("%d",&first_N);

	for(int i = 0; i < first_N; i++){

		scanf("%d %d %d %d",&line[i].x1,&line[i].y1,&line[i].x2,&line[i].y2);

		X.push_back(line[i].x1);
		X.push_back(line[i].x2);
		Y.push_back(line[i].y1);
		Y.push_back(line[i].y2);
	}

	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());
	for(int i = 0; i < X.size(); i++){

		map_X[X[i]] = i;
	}

	sort(Y.begin(),Y.end());
	Y.erase(unique(Y.begin(),Y.end()),Y.end());
	for(int i = 0; i < Y.size(); i++){

		map_Y[Y[i]] = i;
	}

	N = 1;
	init(2*first_N); //★★1つの線分につき2点あるから、2*first_Nで初期化する★★
	Type type;
	int loc,mini,maxi;

	for(int i = 0; i < first_N; i++){

		if(line[i].x1 == line[i].x2){

			type = TATE;
			loc = map_X[line[i].x1];
			mini = map_Y[min(line[i].y1,line[i].y2)];
			maxi = map_Y[max(line[i].y1,line[i].y2)];

		}else{

			type = YOKO;
			loc = map_Y[line[i].y1];
			mini = map_X[min(line[i].x1,line[i].x2)];
			maxi = map_X[max(line[i].x1,line[i].x2)];
		}

		//垂直交差チェック
		if(isCross(loc,mini,maxi,rev[type])){

			printf("0\n");
			continue;
		}

		//水平交差チェック
		auto at = SET[type][loc].lower_bound(make_pair(mini,maxi));
		//右側チェック
		if(at != SET[type][loc].end()){

			if(maxi < at->first || mini > at->second){

				//Do nothing
			}else{
				printf("0\n");
				continue;
			}
		}
		//左側チェック
		if(at != SET[type][loc].begin()){

			at--;
			if(maxi < at->first || mini > at->second){

				//Do nothing
			}else{
				printf("0\n");
				continue;
			}
		}

		printf("1\n");
		add(mini,maxi,loc,0,0,N-1,type);
		SET[type][loc].insert(make_pair(mini,maxi));
	}

	return 0;
}



Measured memory_bytes: 181604
import java.util.*;

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

        int N = sc.nextInt();

        int[] loc = new int[N];
        for (int i = 0; i < N; i++) {
            loc[i] = sc.nextInt();
        }

        Arrays.sort(loc);

        int ans = loc[N - 1] - loc[0];

        System.out.println(ans);

    }

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int cnt;
char B[13];
int main(){
    string A;
    
    cin>>A;
    
   for(int i=0;i<A.size();i++)
   {
       if(A[i]!='B')
       {
           B[cnt]=A[i];
           cnt++;
          
       }
       else
       {
           if(cnt!=0)
           {
               cnt--;
           }
       }
   }
   for(int i=0;i<cnt;i++)
   {
       printf("%c",B[i]);
   }
    
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) {
        int a, b;

        try (InputScanner is = new InputScanner(System.in)) {
            a = is.ni();
            b = is.ni();
        }
        int result = 0;
        result += prime(a);
        result += prime(b);
        if (a ==1 && b ==1){
            result += 400000;
        }

        System.out.println(result);
    }

    private static int prime(int n){
        if ( n ==3){
            return 100000;
        }
        if ( n ==2){
            return 200000;
        }
        if ( n ==1){
            return 300000;
        }
        return 0;
    }
    //-------------------------------------------------------------------
    public static class InputScanner implements Closeable {
        private final BufferedReader br;
        private String[] element;
        private int elementIndex;

        public InputScanner(InputStream is) {
            this.br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            return this.nextElement();
        }

        //next int
        public int ni() {
            return Integer.parseInt(this.nextElement());
        }

        //next long
        public long li() {
            return Long.parseLong(this.nextElement());
        }

        //next int array
        public int[] nia(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = this.ni();
            }
            return arr;
        }

        private void readLine() {
            try {
                this.element = this.br.readLine().split("\\s");
            } catch (IOException e) {
                e.printStackTrace();
            }
            this.elementIndex = 0;
        }

        private String nextElement() {
            if (!hasElement()) {
                this.readLine();
            }
            return this.element[this.elementIndex++];
        }

        private boolean hasElement() {
            return this.element != null && this.element.length > this.elementIndex;
        }

        @Override
        public void close() {
            if (this.br != null) {
                try {
                    this.br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
//-------------------------------------------------------------------
}


Measured memory_bytes: 24660
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main(){
    int N, a[110];

    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];

    int C[9]={0};
    for(int i = 0; i < N; i++){
        if(a[i] < 400) C[0]++;
        else if(a[i] < 800) C[1]++;
        else if(a[i] < 1200) C[2]++;
        else if(a[i] < 1600) C[3]++;
        else if(a[i] < 2000) C[4]++;
        else if(a[i] < 2400) C[5]++;
        else if(a[i] < 2800) C[6]++;
        else if(a[i] < 3200) C[7]++;
        else C[8]++;
    }

    int cmin=0, cmax=0;
    for(int i = 0; i < 8; i++){
        if(0 < C[i]){
            cmin++; cmax++;
        }
    }

    cmax += C[8];
    if(cmin == 0) cmin = 1;

    cout << cmin << " " << cmax << endl;


    return 0;
}


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

int main() {
    int64_t a, b, k;
    cin >> a >> b >> k;
    int64_t ans = 0;
    b = (k - a > 0 ? max(0L, b - (k - a)) : b);
    a = max(0L, a - k);
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=105;

struct Edge {
	int from,to,cap,flow,cost;
	Edge(int u,int v,int c,int f,int w):from(u),to(v),cap(c),flow(f),cost(w) {}
};

int n,m,tf;
vector<Edge>edges;
vector<int>G[maxn];
bool inq[maxn];
int d[maxn];
int a[maxn];
int p[maxn];


inline void addedge (int u,int v,int c,int w) {
	edges.pb(Edge(u,v,c,0,w));
	edges.pb(Edge(v,u,0,0,-w));
	int id=edges.size()-2;
	G[u].pb(id);
	G[v].pb(id+1);
}

inline bool spfa (int s,int t,int& flow,int& cost) {
	for (int i=0;i<n;i++) d[i]=INF;
	d[s]=0; inq[s]=1; a[s]=max(0,tf-flow);
	queue<int>q;
	q.push(s);
	while (q.size()) {
		int u=q.front(); q.pop();
		inq[u]=0;
		for (int id:G[u]) {
			Edge& e=edges[id];
			if (e.cap>e.flow && d[e.to]>d[u]+e.cost) {
				d[e.to]=d[u]+e.cost;
				p[e.to]=id;
				a[e.to]=min(a[u],e.cap-e.flow);
				if (!inq[e.to]) {inq[e.to]=1;q.push(e.to);}
			}
		}
	}
	if (d[t]==INF) return 0;
	flow+=a[t];
	cost+=d[t]*a[t];
	// cout<<flow<<' '<<cost<<'\n';
	for (int u=t;u!=s;u=edges[p[u]].from) {
		edges[p[u]].flow+=a[t];
		edges[p[u]^1].flow-=a[t];
	}
	return 1;
}

inline int mcmf (int s,int t) {
	int flow=0 , cost=0;
	while (spfa(s,t,flow,cost) && flow<tf);
	if (flow<tf) return -1;
	else return cost;
}

int main() {
	cin>>n>>m>>tf;
	for (int i=0;i<m;i++) {
		int u,v,c,w; cin>>u>>v>>c>>w;
		addedge(u,v,c,w);
	}
	cout<<mcmf(0,n-1)<<'\n';
}


Measured memory_bytes: 3200
/*
 * Created By : pash123
 * 2020-08-29-17.20
*/


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

const int M=1e9+7;

int main()
{
    string s,t;
    cin>>s>>t;
    vector<int> ans;
    int n=(int)s.size();

    int left=0;
    int right=(int)(t.size()-1);
    while(right<n)
    {
        int k=0;
        int cnt=0;
        for(int i=left;i<=right;++i)
        {
            if(s[i]!=t[k])
                cnt++;
            k++;
        }
        ans.push_back(cnt);
        left++;
        right++;
    }
    sort(ans.begin(),ans.end());
    cout<<ans[0];
    return 0;
}


Measured memory_bytes: 3608
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

int main()
{
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int count = 0;
	while (true)
	{
		bool exist_odd = false;
		for (int i = 0; i < n; i++)
		{
			if (a[i] % 2 != 0)
			{
				exist_odd = true;
			}
		}
		if (exist_odd == true)
		{
			break;
		}
		for (int i = 0; i < n; i++)
		{
			a[i] /= 2;
		}
		count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                9000000000000000000
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (const pair<db,ll>  p1, const pair<db,ll> p2){
        return (p1.first ==  p2.first) ? p1.ss < p2.ss : p1.first > p2.first;
    }
};

int main(){
    FIO;
    ll n,m,k; cin >> n >> m >> k;
    ll arr[n], arr2[m];
    forn(i,0,n) cin >> arr[i];
    forn(i,0,m) cin >> arr2[i];
    ll ans = 0;
    ll sum = 0;
    forn(i,0,m){
        sum += arr2[i];
        arr2[i] = sum;
    }
    sum = 0;
    forn(i,0,n+1){
        ll temp = 0;
        //dbg(sum);
        if(sum <= k){
            temp = -1;
            ll s = 0, e = m-1;
            while(s <= e){
                ll mid = (s+e)>>1;
                if(arr2[mid] <= k-sum){
                    temp = max(temp,mid);
                    s = mid+1;
                }else{
                    e = mid-1;
                }
            }
            //dbg(temp);
            temp = temp+1+i;
            if(temp >= ans) ans = temp;
        }
        if(i == n) break;
        sum += arr[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
int N,i;
double A,T;
cin >> N ;
cin >> T >> A;
double best ;
int H[N],answer;
for ( i = 0;i < N;i++)
	cin >> H[i];
best = abs(A - (T - 0.006*H[0]));
for ( i = 0;i < N;i++) {
	
	if (abs(A - (T - 0.006*H[i])) <=best) {
		best = abs(A - (T - 0.006*H[i]));
		answer = i;
	}
}


cout << answer+1<< endl;

}

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

using namespace std;

int main() {
    int n, q;
    cin >> n;
    vector<int> s(n);
    for(int i=0; i<n; ++i) cin >> s[i];
    cin >> q;
    int res = 0;
    for(int j=0; j<q; ++j) {
        int t;
        cin >> t;
        for(int i=0; i<n; i++) {
            if(s[i]==t) {
                res++;
                break;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3088
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 2000010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}

int main(){
  FAST;
  comi();
  LL i,ans=0,r1,c1,r2,c2;
  cin>>r1>>c1>>r2>>c2;
  FOR(i,c1,c2+1){
    ans+=com(r2+i+1,r2)-com(r1+i,r1-1);
    ans=mod(ans,MOD);
  }
  cout<<ans<<endl;
}


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

int main(){
  int i,array[200001]={},b,c;
  string s;
  cin>>s;
  
  for(i=0;i<s.size();i++){
    if(s[i]=='A'){
      b=i;
      break;
    }
  }
  for(i=s.size()-1;i>0;i--){
    if(s[i]=='Z'){
      c=i;
      break;
    }
  }
  cout<<c-b+1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) {
        cin >> v[i];
        v[i]--;
    }
    int ans = 0;
    REP(i,n) {
        if (i == v[v[i]]) ans++;
    }

    ans /= 2;

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main(void)
{
    int n,x;
    char a,b;

    cin >> a;

    n = a;

    if(n>96){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;
    }

    //b = n;

    //cout << b << endl;
   
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define i64 long long
#define N (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;
bool is_harshad(int n){
	int sumDigit=0, tmp=n;
	while(tmp>0){
		sumDigit+=(tmp%10);
		tmp/=10;
	}
	return n%sumDigit == 0;
}
int main(){
	int n; cin>>n;
	printf("%s\n", is_harshad(n) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  string S;
  cin >> N >> S;
  enum RGBtype : int64_t { kR = 0L, kG, kB, kNumber };
  vector<int64_t> A(N);
  vector<int64_t> counts(3, 0);
  for (int64_t i = 0; i < N; ++i) {
    const char ch = S.c_str()[i];
    if (ch == 'R') {
      A[i] = kR;
      ++counts[kR];
    } else if (ch == 'G') {
      A[i] = kG;
      ++counts[kG];
    } else if (ch == 'B') {
      A[i] = kB;
      ++counts[kB];
    }
  }

  vector<int64_t> rgb_index = {0, 1, 2};
  int64_t result = 1;
  for (const int64_t count : counts) {
    result *= count;
  }

  for (int64_t i = 0; i < N; ++i) {
    for (int64_t j = i + 1; j < N; ++j) {
      const int64_t k = j * 2LL - i;
      if (k < N && A[i] != A[j] && A[j] != A[k] && A[i] != A[k]) {
        --result;
      }
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 3676
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException {
      
		int mod = (int) 1E9 + 7;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] s = br.readLine().toCharArray();
		long dp[][] = new long[s.length][13];

		if ( s[0] == '?' ) {
			for ( int n = 0; n < 10; n++ ) {
				dp[0][n] = 1;
			}
		} else {
			dp[0][s[0] - '0'] = 1;
		}

		for ( int i = 1; i < s.length; i++ ) {
			for ( int r = 0; r < 13; r++ ) {
				if ( s[i] != '?' ) {
					int now = s[i] - '0';
					dp[i][(r * 10 + now) % 13] += dp[i - 1][r];
				}
				else {
					for ( int now = 0; now < 10; now++ ) {
						dp[i][(r * 10 + now) % 13] += dp[i - 1][r];
					}
				}
			}

			for ( int t = 0; t < 13; t++ ) {
				dp[i][t] %= mod;
			}
		}
		System.out.println(dp[s.length - 1][5]);
		br.close();
	}
}


Measured memory_bytes: 35756
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=100005;
struct edge{
	int to,next;
}e[N*2];
int head[N],tot,n,m,cnt;
int deg[N],vis[N],q4[N];
void add(int x,int y){
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
void findpath(int x,int fa){
	if (x==q4[2])
		return ++cnt,void(0);
	if (x==q4[1]&&fa) return;
	for (int i=head[x];i;i=e[i].next)
		if (e[i].to!=fa)
			findpath(e[i].to,x);
}
int main(){
	scanf("%d%d",&n,&m);
	For(i,1,m){
		int x,y;
		scanf("%d%d",&x,&y);
		++deg[x]; ++deg[y];
		add(x,y); add(y,x);
	}
	int S6=0,S4=0;
	For(i,1,n)
		if (deg[i]&1)
			return puts("No"),0;
		else if (deg[i]>=6) ++S6;
		else if (deg[i]==4) q4[++S4]=i;
	if (S6||S4>=3)
		return puts("Yes"),0;
	if (S4<1)
		return puts("No"),0;
	vis[q4[1]]=vis[q4[2]]=1;
	findpath(q4[1],0);
	puts(cnt==2?"Yes":"No");
}


Measured memory_bytes: 4096
import sys
from bisect import bisect_left

n, q = map(int, input().split())
lines = sys.stdin.readlines()
kkk = []
for line in lines[:n]:
    s, t, x = map(int, line.split())
    kkk.append((x, s, t))
kkk.sort()
ddd = list(map(int, lines[n:]))

ans = [-1] * q
skip = [-1] * q
for x, s, t in kkk:
    ss = bisect_left(ddd, s - x)
    tt = bisect_left(ddd, t - x)
    while ss < tt:
        sk = skip[ss]
        if sk == -1:
            ans[ss] = x
            skip[ss] = tt
            ss += 1
        else:
            ss = sk
print('\n'.join(map(str, ans)))


Measured memory_bytes: 99384
#!/usr/bin/env python2
#encoding: UTF-8

# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
import math
line=raw_input().rstrip().split(' ')
N=int(line[0])
K=int(line[1])
Disto=raw_input().rstrip().split(' ')
Tru=True
while(Tru):
	Tru=False
	for args in Disto:
		for i in range (len(str(N))):
			if str(N)[i]==args:
				N+=1
				Tru=True
print N				

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    for(int i = k; i < n; i++){
        if(a[i] > a[i-k]){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3980