akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<cstring>
using namespace std;

#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
///////////////////////////



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

	string s;
	cin >> s;
	//2017/01/07
	s[3] = '8';
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 892
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 4 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    string t = "ACGT";

    string s;
    cin>>s;

    int counter =0;
    int tempcounter = 0;
    for(int i=0; i<s.size(); ++i){
        if(s[i]=='A' or s[i]=='G' or s[i]=='C' or s[i]=='T'){
            ++tempcounter;
            counter = max(counter  , tempcounter);
        }else{
            tempcounter = 0; 
        }
    }

    cout<<counter<<endl;

    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("bin","r",stdin);
    freopen("bout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();
			final int K = s.nextInt();
			final String S = s.next();
			List<Integer> list = new ArrayList<>();
			char c = '1';
			int n = 0;
			for (int i = 0; i < N; i++) {
				if (c != S.charAt(i)) {
					list.add(n);
					c = S.charAt(i);
					n = 1;
				} else {
					n++;
				}
			}
			list.add(n);

			int ret = 0;
			for (int i = 0; i < list.size(); i += 2) {
				int END = i + 2 * K;
				int sum = 0;
				for (int j = i; j < list.size() && j <= END; j++) {
					sum += list.get(j);
				}
				ret = Math.max(ret, sum);
			}

			System.out.println(ret);
		}
	}
}


Measured memory_bytes: 26204
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    string s;cin>>s;
    sort(s.begin(),s.end());
    for(int i=1;i<(int)s.length();i++){
        if(s[i]==s[i-1]){
            cout<<"no"<<endl;
            return 0;
        }
    }
    cout<<"yes"<<endl;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mkmap;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<vi> vv;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const ll mod=1000000007;
const int sz=1000001;
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(i=a;i<b;++i)
#define rrep(i,a,b) for(i=a;i>=b;--i)
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db(x) cout << (#x) << " = " << x << endl;

inline ll mult(ll a, ll b) {return (((a % mod) * (b % mod)) % mod);}

double dp[3001][1501];

double fun(vector<double> &a,int i,int p){
    if(p>(a.size()/2)) return 0;
    if(i>=a.size()) return 1;
    if(dp[i][p]!=-1) return dp[i][p];
    return dp[i][p]=a[i]*fun(a,i+1,p)+(1-a[i])*fun(a,i+1,p+1);
}

int main(){
    fast;
    int t,tt,tti,n,m,x,y,z,i,j,k,temp,count,o,e,f,ans,sum,l,r,mx,mn;
    ll lx,ly,lz,ltemp;
    double fx,fy,fz;
    string s;
    
    cin>>n;
    rep(i,0,n+1){
        rep(j,0,n/2+2) dp[i][j]=-1;
    }
    vector<double> a(n);
    for(auto &p:a) cin>>p;
    cout<<setprecision(10)<<fun(a,0,0);
}

/*
    
*/

Measured memory_bytes: 39164
import java.util.*;
 
public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
 
        long h = stdIn.nextLong();
        //int c = stdIn.nextInt();
        //int x = stdIn.nextInt();
        //String s = stdIn.next();
        //String t = stdIn.next();
        //char c[] = s.toCharArray();
        //c[0] += 1;
        long sum = 0;
        //boolean flag = true;
        int count = 0;
        while(true){
            if(h == 1){
                break;
            }else{
                count++;
                h /= 2;
            }
        }
        
        for(int i = 0; i <= count; i++){
            sum += Math.pow(2, i);
        }
        
        // if(sum >= h){
        //     System.out.println("Yes");
        // }else{
        //     System.out.println("No");
        // }
        
        System.out.println(sum);
 
        //System.out.println();
        //System.out.print();
 
        stdIn.close();
    }
}

Measured memory_bytes: 23764
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    res = [["#"] * (W + 2)]
    for _ in range(H):
        a = list(input())
        res.append(["#"] + a + ["#"])
    res.append(["#"] * (W + 2))
    for i in res:
        print("".join(i))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 38416
# -*- coding: utf-8 -*-
import sys

N = int(input())
S_count = {}
for n in range(N):
    s = input()
    if s not in S_count:
        S_count[s] = 0
    S_count[s] += 1

max_count = 0
max_strings = []
for k, v in S_count.items():
    if v > max_count:
        max_strings = []
        max_strings.append(k)
        max_count = v
    elif v == max_count:
        max_strings.append(k)

#print(max_strings)

# 辞書順に並び替え
sorted_strings = sorted(max_strings)

#print(sorted_strings)
for s in sorted_strings:
    print(s)

Measured memory_bytes: 32988
#include <bits/stdc++.h>
using namespace std;
int main(){
int K;
  cin>>K;
    int sum=0;
    for(int a=1;a<=K;a++){
     for(int b=1;b<=K;b++){
      for(int c=1;c<=K;c++){
      	sum+=gcd(a,gcd(b,c));
      }
     }
    }
  cout<<sum<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 2e5 + 7;
int dp[3][3000]; //状态dp[i][j]表示以第i字符结尾的数字中对2019取模为j的数字有多少个
char s[maxx];

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    LL ans = 0;
    for(int i = 1; i <= n; i++) {
        int x = s[i] - '0';
        for(int j = 0; j <= 2019; j++) {
            dp[1][(j * 10 + x) % 2019] += dp[0][j];
        }
        dp[1][x]++;
        for(int j = 0; j <= 2019; j++) {
            dp[0][j] = dp[1][j];
            dp[1][j] = 0;
        }
        ans += dp[0][0];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

int main(){
    int k, x; cin >> k >> x;

    cout << ((500*k >= x)?"Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 3628
N, K = list(map(int, input().split()))
A = list(map(lambda x: int(x) - 1, input().split()))

now = 0
seen = []
while True:
    seen.append(now)
    teleporter = A[now]
    A[now] = 'used'
    if teleporter == 'used':
        break
    else:
        now = teleporter  

loop_s = seen.index(now)
size = len(seen) - loop_s - 1

if K <= loop_s:
    print(seen[K] + 1)
else:
    print(seen[loop_s +(K - loop_s) % size] + 1)

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

#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define si second
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define AS 200001
#define mod 1000000007
#define inf 1e9
int solve(vector<int>ar, int n) {
	vector<int>dp(n + 1);
	dp[0] = 1;
	for (int i = 2; i <= n; i++) {
		int option1 = abs(ar[i] - ar[i - 1]) + dp[i - 1];
		int option2 = (i == 2) ? inf : abs(ar[i] - ar[i - 2]) + dp[i - 2];
		dp[i] = min(option1, option2);
	}
	return dp[n];
}
int main() {
	fastIO

	int n;
	cin >> n;
	vector<int>ar;
	ar.resize(n + 1);
	F1(ar, n);
	cout << solve(ar, n) << endl;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0) break;
            for(int i = 0; i < h; i++) {
                for(int j = 0; j < w; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
        
    }
}


Measured memory_bytes: 34884
N = int(input())

def dist(A, B):
    return abs(A[0] - B[0]) + abs(A[1] - B[1])

XY = [tuple(map(int, input().split())) for _ in range(N)]
INF = -10**10

ans = 0
for O in [(INF, INF), (-INF, INF)]:
    S = XY[0]
    for xy in XY:
        if dist(O, S) < dist(O, xy):
            S = xy
    O = S
    for xy in XY:
        if dist(O, S) < dist(O, xy):
            S = xy
    ans = max(ans, dist(O, S))
print(ans)



Measured memory_bytes: 36016
#include <stdio.h>

using namespace std;

int main(){
    int N;
    scanf("%d",&N);
    int a,b,c;
    for(int i = 0; i < N; ++i){
        scanf("%d %d %d",&a,&b,&c);
        if(a*a+b*b==c*c || a*a+c*c == b*b || b*b+c*c==a*a) {
            printf("YES\n");
            continue;
        }
        printf("NO\n");
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<long long> l(n);
  int cnt=0;

  for(int i=0;i<n;i++) cin >> l.at(i);

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        int ii,jj,kk;
        ii=l.at(i);
        jj=l.at(j);
        kk=l.at(k);
        if(ii!=jj && jj!=kk && kk!=ii){
          if(ii+jj>kk && jj+kk>ii && kk+ii>jj){
            cnt++;
          }
        }
      }
    }
  }

  cout << cnt << endl;

}

Measured memory_bytes: 3644
/*
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,now,mn,mx,tot,v[1000001],g[1000001],mex[1000001],e[1000001],hd[1000001],nt[1000001],fa[1000001];
void build(int t,int k){
	tot++;
	e[tot]=k;
	nt[tot]=hd[t];hd[t]=tot;
}
void dfs(int x){
	int i;
	for(i=hd[x];i;i=nt[i]){
		if(v[e[i]])continue;
		dfs(e[i]);
		g[mex[e[i]]]=1;
	}
	for(i=0;;i++)if(!g[i])break;
	mex[x]=i;
	for(i=hd[x];i;i=nt[i])if(!v[e[i]])g[mex[e[i]]]=0;
}
int main(){
	int i,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&fa[i]);
		build(fa[i],i);
	}
	x=1;
	while(!v[x])v[x]=1,x=fa[x];
	memset(v,0,sizeof(v));
	while(!v[x])v[x]=1,x=fa[x];
	mn=n+1;mx=-1;
	for(i=1;i<=n;i++){
		if(!v[i])continue;
		now^=1;
		dfs(i);
		mx=max(mx,mex[i]);
		mn=min(mn,mex[i]);
	}
	if(now&&mn==mx)puts("IMPOSSIBLE");
	 else puts("POSSIBLE");
}
*/
#include<bits/stdc++.h>
using namespace std;

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}

inline void upmax(int &x,const int &y){if(y>x) x=y;}
inline void upmin(int &x,const int &y){if(y<x) x=y;}

const int N=200010;
struct Edge{int to,next;} e[N];
int h[N],sum=0,n;
int fa[N],mex[N];
bool vis[N],loop[N];
bool have[N];

void add_edge(int u,int v)
{
    e[++sum].to=v;
    e[sum].next=h[u];
    h[u]=sum;
}

void dfs(int u)
{
    for(int t=h[u];t;t=e[t].next)
        if(!loop[e[t].to]) dfs(e[t].to);
    for(int t=h[u];t;t=e[t].next)
        if(!loop[e[t].to]) have[mex[e[t].to]]=1;
    while(have[mex[u]]) mex[u]++;
    for(int t=h[u];t;t=e[t].next)
        if(!loop[e[t].to]) have[mex[e[t].to]]=0;
}

int main()
{
    int n,x=1;
    n=read();
    for(int i=1;i<=n;i++)
    {
        fa[i]=read();
        add_edge(fa[i],i);
    }
    while(!vis[x]) vis[x]=1,x=fa[x];
    while(!loop[x]) loop[x]=1,x=fa[x];
    int mx=-1,mn=n+1,cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(!loop[i]) continue;
        dfs(i);cnt++;
        upmax(mx,mex[i]);
        upmin(mn,mex[i]);
    }
    puts(mx==mn&&(cnt&1)?"IMPOSSIBLE":"POSSIBLE");
    return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <functional>
#include <tuple>
#include <array>

template<class T>
struct segment_tree {
	using value_type = T;
	using F = std::function<T(T, T)>;
private : 
	int n;
	const F f;
	const value_type ie;
	std::vector<value_type> node;

public : 
	segment_tree (const F &f, const value_type &ie) : f(f), ie(ie) { }

	void resize (int _n) noexcept {
		n = 1;
		while (n < _n) n <<= 1;
		node.resize(2 * n);
		std::fill(node.begin(), node.end(), ie);
	}

	void resize (int _n, const value_type &e) noexcept {
		n = 1;
		while (n < _n) n <<= 1;
		node.resize(2 * n);
		std::fill(node.begin(), node.end(), ie);
		for (int i = n; i < 2 * n; i++) node[i] = e;
		for (int i = n; i--> 0;) {
			node[i] = f(node[i << 1 | 0], node[i << 1 | 1]);
		}
	}

	template<class iter>
	void build (iter l, iter r) {
		resize(r - l);
		for (int i = n; l != r; i++, l++) node[i] = *l;
		for (int i = n; i--> 0;) {
			node[i] = f(node[i << 1 | 0], node[i << 1 | 1]);
		}
	}

	void set_val (int i, const value_type &x) {
		i += n;
		node[i] = x;
		for (i >>= 1; i > 0; i >>= 1) {
			node[i] = f(node[i << 1 | 0], node[i << 1 | 1]);
		}
	}

	constexpr value_type fold (int l, int r) {
		value_type vl = ie, vr = ie;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (l & 1) vl = f(vl, node[l++]);
			if (r & 1) vr = f(node[--r], vr);
		}
		return f(vl, vr);
	};

	constexpr const value_type& fold_all() const {
		return (node[1]);
	}

	constexpr const value_type& operator[] (int i) const {
		return node[i + n];
	}

};


constexpr int INF = (1 << 30);

int main() {
	std::size_t n;
	std::cin >> n;
	std::vector<std::pair<int, int>> dat;

	for (std::size_t i = 0; i < n; i++) {
		int e;
		std::cin >> e;
		dat.emplace_back(e, e);
	}
	
	auto f = [](const std::pair<int, int> &l, const std::pair<int, int> &r) {
		int max = std::max(l.first, r.first);
		int min = std::min(l.second, r.second);
		return std::pair<int, int>(max, min);
	};
	segment_tree<std::pair<int, int>> seg(f, std::pair<int, int>(-INF, INF));
	
	seg.build(dat.begin(), dat.end());
	
	int query;
	std::cin >> query;
	while (query--) {
		int ord, l, r;
		std::cin >> ord >> l >> r;
		std::pair<int, int> p = seg.fold(l, r);
		if (ord) std::cout << p.first << '\n';
		else std::cout << p.second << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 3120
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b, c;
	int ans = 0;
	cin >> a >> b >> c;
	if (a == b)
		ans = c;
	else if (b == c)
		ans = a;
	else
		ans = b;
	cout << ans << endl;

} 

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll  A[200000],K,N;
string S,T;

int main(){
  cin >> K >> N;
  rep(i,N){
    cin >> A[i];
  }
  ll Z=LINF;
  rep(i,N){
    if(i!=N-1){
      Z=min(Z,K-(A[i+1]-A[i]));
    }
    else{
      Z=min(Z,A[i]-A[0]);
    }
  }
  cout  << Z <<endl;
}


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

int tax (int X, int i) {
    return i*(100+X)/100;
}

int func (int a, int b, int c) {
    int maximum;
    maximum = 0;
    for (int i = 1; i < c; i++) {
        for (int j = 1; j < c; j++) {
            if (tax(a,i)+tax(a,j) == c) {
                maximum = max(maximum, tax(b,i)+tax(b,j));
            }
        }
    }
    cout << maximum << endl;
}
 
int main() {
    int a, b, c;
    while(true){
      cin >> a >> b >> c;
      if(a+b+c==0)break;
      func(a,b,c);
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define LL long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 2e5 + 10;

pair < LL, LL > a[N], tmp;
LL c[N];
LL dp[100];

bool cmp(pair < LL, LL > A, pair < LL, LL > B) {
    return A.fir * (B.sec + 1) > B.fir * (A.sec + 1);
}

void solve() {

    int n; LL T;
    scanf("%d %lld", &n, &T);
    int cnt1 = 0, cnt2 = 0;
    rep(i, 1, n) {
        scanf("%lld %lld", &tmp.fir, &tmp.sec);
        if(tmp.fir == 0) c[cnt2++] = tmp.sec + 1;
        else a[cnt1++] = tmp;
    }

    sort(c, c + cnt2);
    sort(a, a + cnt1, cmp);

    rep(i, 1, 30) dp[i] = T + 1;
    dp[0] = 0;
    rep(i, 1, cnt2 - 1) c[i] += c[i - 1];

    rep(i, 0, cnt1 - 1) {
        dep(j, 1, 30) {
            dp[j] = min(dp[j], (a[i].fir + 1) * (dp[j - 1] + 1) + a[i].sec);
        }
    }

    int ans = 0;
    rep(i, 0, 30) {
        if(dp[i] > T) continue;
        int add = 0;
        if(cnt2) add = upper_bound(c, c + cnt2, T - dp[i]) - c;
        ans = max(ans, i + add);
    }
    printf("%d\n", ans);
    return ;
}

int main() {

    solve();

    return 0;
}

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

int main() {
    //
    long long num;

    cin >> num;

    vector<long long> vec(num);
    for (int i = 0; i < num; i++) cin >> vec.at(i);

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

    cout << vec.at(num - 1) - vec.at(0);
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string o,e;cin >> o >> e;
  rep(i,e.length()){
    cout << o[i] << e[i];
  }
  if(o.length()>e.length())cout << o[o.length()-1] << endl;
  else cout << endl;
  return 0;
}


Measured memory_bytes: 256
N = [int(i) for i in input()]
n = N[::-1]+[0]
for i in range(len(n)-1):
    if n[i] >= 6 or (n[i] == 5 and n[i+1] >= 5):
        n[i] = 10 - n[i]
        n[i+1] += 1
print(sum(n))


Measured memory_bytes: 28272
#include<bits/stdc++.h>
using namespace std;
long long  dis[1000][1000];
bool vis[1000];
long long w[1000];
long long num,n,m,r,ans=1e18,tmp[1000],x,y,z;
inline void fff()
{
	    for(int k=1;k<=n;k++)
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=n;j++)
	      if(dis[i][k]&&dis[k][j]) dis[i][j]=min(dis[i][k]+dis[k][j],dis[i][j]);
}
void work()
{
		long long tt=0;
		for(int i=1;i<r;i++)
		  tt+=dis[w[i]][w[i+1]];
		ans=min(ans,tt);
}
void dfs(int now)
{
	if(now==r+1) return work();
	for(int i=1;i<=r;i++)
	  if(!vis[tmp[i]]) w[now]=tmp[i],vis[tmp[i]]=1,dfs(now+1),vis[tmp[i]]=0;
}
int main()
{
	scanf("%lld%lld%lld",&n,&m,&r);
	for(int i=1;i<=r;i++)
	  scanf("%lld",&tmp[i]);
	memset(dis,0x3f,sizeof(dis));
	for(int i=1;i<=m;i++)
	  scanf("%lld%lld%lld",&x,&y,&z),dis[x][y]=dis[y][x]=z;
	fff();
	dfs(1);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 8064
class Card():

    def __init__(self):
        self.suit = 0
        self.value = 0


def bubble_sort(c, n):
    for i in range(n):
        for j in range(n - 1, i, -1):
            if c[j].value < c[j - 1].value:
                c[j], c[j - 1] = c[j - 1], c[j]


def selection_sort(c, n):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if c[j].value < c[minj].value:
                minj = j
        c[i], c[minj] = c[minj], c[i]


def is_stable(c1, c2, n):
    for i in range(n):
        if c1[i].suit != c2[i].suit:
            return False
    return True


def print_result(c, n):
    r = []
    for i in range(n):
        r.append(c[i].suit + str(c[i].value))
    print(' '.join(r))


def main():
    n = int(input())
    c1 = [Card() for x in range(n)]
    c2 = [Card() for x in range(n)]
    ary = [x for x in input().split(' ')]

    for i in range(n):
        s, v = list(ary[i])
        c1[i].suit, c1[i].value = s, int(v)
        c2[i].suit, c2[i].value = s, int(v)

    bubble_sort(c1, n)
    selection_sort(c2, n)

    print_result(c1, n)
    print('Stable')
    print_result(c2, n)
    if is_stable(c1, c2, n):
        print('Stable')
    else:
        print('Not stable')


if __name__ == '__main__':
    main()

Measured memory_bytes: 7832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int M = N;
  int sum_dig = 0;
  while(N != 0){
    sum_dig += N % 10;
    N /= 10;
  }
  if(M % sum_dig == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    string str;
    cin>>n>>str;
    if(n>=3200)
        cout<<str<<endl;
    else
        cout<<"red"<<endl;
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# define INF 1000000000
using namespace std;
int v[510][510],n,m,x,y,i,j;
long long s;
int main () {
    cin>>n>>m>>x>>y;
    if(x==y&&x==1){
        cout<<"No\n";
        return 0;
    }
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
            v[i][j]=INF/(x*y);
    for(i=x;i<=n;i+=x)
        for(j=y;j<=m;j+=y)
            v[i][j]=-(x*y-1)*v[1][1]-1;
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
            s+=v[i][j];
    if(s<=0){
        cout<<"No\n";
        return 0;
    }
    cout<<"Yes\n";
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++)
            cout<<v[i][j]<<" ";
        cout<<"\n";
    }
    return 0;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    vector<i64> inc(n + 1);
    for (i64 i = 0; i < n; i++) {
        i64 p;
        cin >> p;
        inc[p] = inc[p - 1] + 1;
    }

    cout << n - *max_element(all(inc)) << endl;
}

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


Measured memory_bytes: 1792
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
using namespace std;

int main() {
	int n;
	cin >> n;
	int x;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {
			cout <<" "<< i;
		}
		else {
			x = i;
			while (x > 0) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
}

Measured memory_bytes: 3084
import math

div1 = 3
div2 = 673

L, R = map(int, input().split())

min_v = 2018

for i in range(L, R):
    for j in range(i + 1, R + 1):
        v = i * j % 2019
        if v == 0:
            print(v)
            exit()
        min_v = min(min_v, v)

print(min_v)


Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	static int[] boo = new int[100000];
	public static void main(String[] args)throws Exception{
		FastScanner sc = new FastScanner();
		
		int n = (sc.nextInt());
		//String[] st = br.readLine().split(" ");
		//boolean[] boo = new boolean[100000];
		
		for (int i = 0; i < n; i++) {
			//boo[Integer.parseInt(st[i])%100000] = 1;
			boo[sc.nextInt()%100000] = 1;
		}
		
		int ans = 0;
		//n = Integer.parseInt(br.readLine());
		n = Integer.parseInt(sc.next());
		//st = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
//			ans += boo[Integer.parseInt(st[i])%100000] ;
			ans += boo[sc.nextInt()%100000] ;
		}
		System.out.println(ans);
	}
	
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 26560
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000ll
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
#include <boost/integer/common_factor_rt.hpp> // gcd, lcm


// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，出現位置，DP
// 余事象，包除
// データ構造
// 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int N;cin >> N;
VI A(N), cntA(N, 0);  
rep(i, 0, N) {
    cin >> A[i];
    ++cntA[A[i]];
}


int64_t cnt = 0;
if (N%2){
    if (cntA[0] == 1) {
        ++cnt;
        rep(i, 1, N/2 + 1)
            if (cntA[2 * i] == 2) {
                cnt *= 2;
                cnt %= MOD;
            }
            else {cout << "0\n"; return 0;}
    }
}
else{
    if (cntA[0] == 0) {
        ++cnt;
        rep(i, 1, N/2 + 1)
            if (cntA[2 * i - 1] == 2) {
                cnt *= 2;
                cnt %= MOD;
            }
            else {cout << "0\n"; return 0;}
    }
}

cout << cnt % MOD << "\n";
}

// 境界，出力文字列 チェック



Measured memory_bytes: 1792
import sys
def input():
    return sys.stdin.readline()[:-1]
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for i in range(n)]
values=[[0]*(w+1) for i in range(n+1)]
# print(values)
for i in range(n):
    values[i+1][wv[i][0]]=max(values[i+1][wv[i][0]],wv[i][1])
    for j in range(1,w+1):
        if values[i][j]!=0:
            if wv[i][0]+j<=w:
                values[i+1][wv[i][0]+j]=max(values[i+1][wv[i][0]+j],values[i][j]+wv[i][1])
            values[i+1][j]=max(values[i+1][j],values[i][j])

print(max(values[-1]))

Measured memory_bytes: 120172
s = input()
t = input()
x = []
y = []
for i in range(len(s)):
    if s[i] not in x:
        x.append(s[i])
    if t[i] not in y:
        y.append(t[i])
for i in range(len(x)):
    s = s.replace(x[i], str(i))
for i in range(len(y)):
    t = t.replace(y[i], str(i))
if s == t:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9608
#include<stdio.h>
int main(){
  int n,m=0,i,M=998244353,a[100010],b[100010]={};
  long long c=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    b[a[i]]++;
    if(m<a[i])m=a[i];
  }
  if(a[0]||b[0]-1){
    printf("0\n");
    return 0;
  }
  for(i=1;i<n;i++)c=(c*b[a[i]-1])%M;
  printf("%lld\n",c);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so sort
#define rev reverse
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans = 0;
  REP(i,4){
    if(s[i] == '+')ans++;
    else ans--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll f(ll n) {
    ll ans = 0;
    reps(i, 1, n + 1) {
        if (n % i == 0) ans++;
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    ll ans = 0;
    reps(i, 1, n + 1) {
        if (i % 2 == 0) continue;
        if (f(i) == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

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

	int sum = 0;

	for (int i = 0; i < N.length(); i++)
	{
		sum += N[i] - '0';
	}

	if (sum % 9 == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;

vector<pint> vp[2][100001];
ll d[2][100001];
ll INF=1000100010001000100;
int n;
int dijkstra(int st,int id){
    priority_queue<pint,vector<pint>,greater<pint> > pq;
    rep(i,n) d[id][i]=INF;
    d[id][st]=0;
    pq.push(make_pair(0,st));
    while(!pq.empty()){
        pint pi=pq.top();pq.pop();
        ll t=pi.second;
        if(d[id][t]<pi.first) continue;
        for(auto it:vp[id][t]){
            if(d[id][it.second]>d[id][t]+it.first){
                d[id][it.second]=d[id][t]+it.first;
                pq.push(make_pair(d[id][it.second],it.second));
            }
        }
    }
}
ll mn[100001];
int main(){
    int m,s,t;
    cin>>n>>m>>s>>t;
    int sr,ds,ai,bi;
    rep(i,m){
        cin>>sr>>ds>>ai>>bi;
        --sr,--ds;
        vp[0][sr].pb(ai,ds);
        vp[0][ds].pb(ai,sr);
        vp[1][sr].pb(bi,ds);
        vp[1][ds].pb(bi,sr);
    }
    rep(i,n+1) mn[i]=INF;
    dijkstra(s-1,0);
    dijkstra(t-1,1);
    for(int i=n-1;i>=0;--i){
        mn[i]=min(mn[i+1],d[0][i]+d[1][i]);
    }
    rep(i,n){
        cout<<1000000000000000-mn[i]<<endl;
    }
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  ll x;
  cin >> x;

  cout << (x/11)*2 + (x%11+5)/6 << endl;

}



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

int main(){
  int n;
  int pay;
  int comeback;
  int result;

  std::cin >> n;

  pay = 800 * n;
  comeback = (n / 15) * 200;
  result = pay - comeback;

  std::cout << result << '\n';
  return 0;
}


Measured memory_bytes: 384
import Data.Char
import Text.Printf

main :: IO ()
main = do
  abcd <- getLine :: IO [Char]
  let zero = ord '0'
  let a:b:c:d:_ = map (\x -> (ord x) - zero) abcd
  let head:_ = [[op1, op2, op3] | op1 <- [-1, 1], op2 <- [-1, 1], op3 <- [-1, 1], a + op1 * b + op2 * c + op3 * d == 7]
  let op1:op2:op3:_ = map (\x -> if x > 0 then '+' else '-') head
  printf "%d%c%d%c%d%c%d=7\n" a op1 b op2 c op3 d



Measured memory_bytes: 508
s=input()
n=len(s)
a=[0]*n
for i in range(n-1):
    if s[i:i+2]=='RL':
        l=i
        r=i+1
        while l>0 and s[l-1]=='R':l-=1
        while r<n-1 and s[r+1]=='L':r+=1
        a[i]=(i-l)//2+1+(r-i)//2
        a[i+1]=(i-l+1)//2+(r-i-1)//2+1
print(*a)

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

int H, W, cnt; char c[10][10];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) { cin >> c[i][j]; if (c[i][j] == '#') cnt++; }
	}
	if (cnt == H + W - 1) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main (){
  ll a,b,c;
  cin>>a>>b>>c;
  ll ans=min(b/a,c);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 100 * 1000 + 47;

int A[MAX];

int main()
{
   
    int n;
    scanf("%d", &n);
    FOR(i, 0,n)
    scanf("%d", A + i);
    
    
    sort(A, A + n);
    reverse(A, A + n);
    
    int x = 0, y = 0;
    
    while(true)
    {
        if (y + 1 == n)break;
        if (x + 1 >= A[y + 1])break;
        x++, y++;
    }
    
   // cout << x << " " << y << endl;
    
    int a = A[y] - x - 1, b = 0;
    while(A[y+1] > x)b++, y++;
    
  //  cout << a << " " << b << endl;
    if ((a & 1) == 0 && (b & 1) == 0)
        cout << "Second" << endl;
    else
        cout << "First" << endl;
    
}


Measured memory_bytes: 640
// D - Prediction and Restriction
#include <bits/stdc++.h>
using namespace std;

map<char,char> win={{'r','p'},{'s','r'},{'p','s'}};
map<char,int> point={{'r',0},{'s',0},{'p',0}};

int main(){
	int N,K; string T;
	cin>>N>>K>>point['r']>>point['s']>>point['p']>>T;
	int ans = 0;
	for(int i=0; i<N; ++i){
		ans += point[win[T[i]]];
		if(i-K >= 0 && T[i-K] == T[i]){
			ans -= point[win[T[i]]];
			T[i] = '-';
		}
	}
	cout<< ans <<endl;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Y);
    REP(i, X) cin >> A[i];
    REP(i, Y) cin >> B[i];
    REP(i, Z) cin >> C[i];
    sort(all(A));
    sort(all(B));
    sort(all(C));

    using quad = tuple<ll, int, int, int>;
    using tri = tuple<int, int, int>;
    priority_queue<quad> q;
    set<tri> used;
    q.push(quad(A[X - 1] + B[Y - 1] + C[Z - 1], X - 1, Y - 1, Z - 1));
    while (K > 0) {
        ll score;
        int i, j, k;
        tie(score, i, j, k) = q.top();
        q.pop();
        if (used.count(tri(i, j, k)) > 0) {
            continue;
        }
        used.insert(tri(i, j, k));
        K--;
        //printf("i = %d, j = %d, k = %d, score = %lld\n", i, j, k, score);
        cout << score << "\n";
        if (i > 0) {
            q.push(quad(A[i - 1] + B[j] + C[k], i - 1, j, k));
        }
        if (j > 0) {
            q.push(quad(A[i] + B[j - 1] + C[k], i, j - 1, k));
        }
        if (k > 0) {
            q.push(quad(A[i] + B[j] + C[k - 1], i, j, k - 1));
        }
    }
    cout << flush;

    return 0;
}

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

using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;long long p=0;
 cin>>t;
 for(int i=1;i<=t;i++){
   if(i%3!=0 && i%5!=0)p+=i;
 }
 cout<<p;
   return 0;
}

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

int main(){
	string s;
	cin >> s;
	if(s.at(0) == s.at(1) && s.at(1) == s.at(2)){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdlib.h>
#include<map>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
#include<cstdlib>
const int MAX=1e5+10;
long long n,m;
int a[MAX];
int main()
{
    cin>>n>>m;
    long long sum;
    if(n>2&&m>2)
        sum=(n-2)*(m-2);
    else if(n==2||m==2)
        sum=0;
    else if(n==1&&m==1)
        sum=1;
    else
        sum=max(n,m)-2;
    if(sum<0)
        sum=0;
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
////////////////////////////////////////

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    
    string s;cin>>s;
    int n=s.size();
    rep(i,0,n-2){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
    }
    rep(i,0,n-3){
        if(s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
    return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	h := scanInt(sc)
	_ = scanInt(sc)
	grid := make([]string, 2*h)
	for i := range loop0(h) {
		grid[2*i] = scanString(sc)
		grid[2*i+1] = grid[2*i]
	}
	for _, str := range grid {
		fmt.Println(str)
	}
	return
}

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop1(n int) chan int {
	return loop(1, n, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

from itertools import product

N,M = map(int,input().split())
S = [list(map(int,input().split()))[1:] for _ in range(M)]
P = list(map(int,input().split()))

ans = 0
for p in product([0,1],repeat=N):
    can = 0
    for i in range(M):
        res = 0
        for s in S[i]:
            if p[s-1] == 1:
                res += 1
        res %= 2
        if res == P[i]:
            can += 1
    if can == M:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int mod(int x){
  if(x>0)return x;
  return -x;
}
int main(){
  int n,k;
  cin>>n>>k;
  int h[n],result[n];
  for(int i=0;i<n;i++)cin>>h[i];
  for(int i=0;i<=k && i<n;i++)result[i]=mod(h[i]-h[0]);
  for(int i=k+1;i<n;i++){
    int min=INT_MAX;
    for(int j=i-k;j<i;j++){
     int flag=result[j]+mod(h[i]-h[j]);
      if(min>flag)min=flag;
    }
      result[i]=min;
  }
  cout<<result[n-1];
  return 0; 
}


Measured memory_bytes: 1024