akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const ll INF=1e18;
const int MOD=1e9+7;

int H,W;
int ch,cw; 
int dh,dw; 
char s[1005][1005];
bool used[1005][1005];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};
ll ans[1005][1005];

void solve(){
    for(int i=0;i<1005;i++){
        for(int j=0;j<1005;j++){
            ans[i][j]=INF;
            used[i][j]=false;
        }
    }
    used[ch][cw]=true;
    ans[ch][cw]=0;
    deque<P> que;
    que.push_back({ch,cw});
    while(!que.empty()){
        P q=que.front(); que.pop_front();
        int x=q.first; int y=q.second;
        for(int i=0;i<4;i++){
            int nx=x+dx[i];
            int ny=y+dy[i];
            if(nx>=0&&ny>=0&&nx<H&&ny<W&&s[nx][ny]=='.'){
                if(used[nx][ny]) continue;
                used[nx][ny]=true;
                ans[nx][ny]=ans[x][y];
                que.push_front({nx,ny});
            }
        }
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                int nx=x+i;
                int ny=y+j;
                if(nx>=0&&ny>=0&&nx<H&&ny<W&&s[nx][ny]=='.'){
                    if(ans[nx][ny]>ans[x][y]+1){
                        ans[nx][ny]=ans[x][y]+1;
                        que.push_back({nx,ny});
                    }
                }
            }
        }
    }
}

int main(){
    cin >> H >> W;
    cin >> ch >> cw; ch--; cw--;
    cin >> dh >> dw; dh--; dw--;
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> s[i][j];
        }
    }
    solve();
    if(ans[dh][dw]!=INF){
        cout << ans[dh][dw] << endl;
    }else{
        cout << -1 << endl;
    }

}

Measured memory_bytes: 13492
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
using namespace std;

// Debug Vector
template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v)
{
    if (!v.empty())
    {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p)
{
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}

typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, C;
    int A[110][110], B[100];
    int sum = 0, cnt = 0;

    cin >> N >> M >> C;
    for (int i = 0; i < M; ++i)
    {
        cin >> B[i];
    }
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < M; ++j)
        {
            cin >> A[i][j];
            sum += A[i][j] * B[j];
        }
        if (sum + C > 0)
        {
            cnt++;
        }
        sum = 0;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        int a = scan.nextInt();
        int b = scan.nextInt();
        int ans=0;
        double[][] x = new double[a][b];
        for(int i=0;i<a;i++){
            for(int l=0;l<b;l++){
                x[i][l]=scan.nextDouble();
            }
        }
        for(int i=0;i<a-1;i++){
            for(int p=i+1;p<a;p++){
                double e = 0;
                for(int l=0;l<b;l++){
                    e+=Math.pow(Math.abs(x[i][l]-x[p][l]),2);
                }
                if(Math.sqrt(e)%1==0)ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24660
#include <stdio.h>
int main(void){
    int a,b,c,cnt=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a==5) cnt++;
    if(b==5) cnt++;
    if(c==5) cnt++;
    if(a+b+c==17 && cnt==2)
        printf("YES\n");
    else
        printf("NO\n");
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) ((X) = ((X) + (Y) % mod) % mod)

int n, m;
int g[20][20];
int dp[1<<15][15];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, n)rep(j, n) g[i][j] = INT_MAX;
    rep(i, m) {
        int s, t, d;
        cin >> s >> t >> d;
        g[s][t] = d;
    }

    rep(i, 1<<n)rep(j, n) dp[i][j] = INT_MAX;
    int start = 0;
    dp[1<<start][start] = 0;

    rep(i, 1<<n) {
        rep(j, n) {
            if (i>>j & 1) {
                rep(k, n) {
                    dp[i][j] = min(dp[i][j], dp[i^(1<<j)][k] + g[k][j]);
                }
            }
        }
    }
    int ans = INT_MAX;
    rep(j, n) ans = min(ans, dp[(1<<n) - 1][j] + g[j][start]);
    cout << (ans == INT_MAX ? -1 : ans) << endl;
}

Measured memory_bytes: 6972
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long



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

    int n,k; cin >> n >> k;
    int ans = 0;
    int t = 1;
    for(;;){
        if(n >= t){
            ans += 1;
            t *= k;
        }else{
            break;
        }
    }

    cout << ans << endl;
}

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

int main(void) {
	int n;
	int x[100] = { 0 };
	int total = 0, mean;
	int ans = 0, ans2=0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &x[i]);

	for (int i = 0; i < n; i++)total += x[i];
	mean = total / n;

	for (int i = 0; i < n; i++) {
		ans += (x[i] - mean) * (x[i] - mean);
	}

	for (int i = 0; i < n; i++) {
		ans2 += (x[i] - mean - 1) * (x[i] - mean - 1);
	}
	if (ans < ans2) printf("%d", ans);
	else printf("%d", ans2);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int ans1=0,ans2=0;
ld akt=-1;
int a,b,c,d,e,f;

int get(int maxi){
	bitset<3005>dp;
	dp.reset();
	dp[0]=true;
	int ans=0;
	for (int i=0;i<=maxi-c;i++) if (dp[i])dp[i+c]=true;
	for (int i=0;i<=maxi-d;i++) if (dp[i])dp[i+d]=true;
	for (int i=0;i<=maxi;i++) if (dp[i])ans=i;
	return ans;
}

int32_t main()
{
  BOOST;
	cin>>a>>b>>c>>d>>e>>f;
	for (int i=0;a*i*100<=f;i++){
		for (int j=0;a*i*100+j*b*100<=f;j++){
			if (!i && !j)continue;
			int water=a*i+j*b;water*=100;
			int maxi=min(f-water,water*e/100);
			int sugar=get(maxi);
			if ((ld)sugar/(sugar+water)>akt)ans1=sugar+water,ans2=sugar,akt=((ld)sugar/(sugar+water));
		}
	}
	
	
	cout<<ans1<<" "<<ans2;
  return 0;
}


Measured memory_bytes: 3592
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	double r;
	cin>>r;
	cout<<r*2*3.1415926<<endl;
	return 0;
}

Measured memory_bytes: 3800
import java.io.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public static int[][] base = {
		{0, 0, 0}, {0, 0, 255}, {0, 255, 0}, {0, 255, 255},
		{255, 0, 0}, {255, 0, 255}, {255, 255, 0}, {255, 255, 255}
	};
	
	public static String[] base_name = {
		"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"
	};
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		while((line = in.readLine()) != null){
			if(line.equals("0")) break;
			
			int[] color = new int[3];
			color[0] = hex2num(line.substring(1, 3));
			color[1] = hex2num(line.substring(3, 5));
			color[2] = hex2num(line.substring(5, 7));
			String name = "";
			int min = Integer.MAX_VALUE;
			for(int i=0; i<base.length; i++){
				int val = delta(base[i], color);
				if(val < min){
					min = val;
					name = base_name[i];
				}
			}
			
			System.out.println(name);
		}
	}
	
	public int delta(int[] a, int[] b){
		int ans = 0;
		for(int i=0; i<3; i++){
			int d = a[i] - b[i];
			ans += d * d;
		}
		return ans;
	}
	
	public int hex2num(String h){
		String[] rigid = new String[]{
				"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"
		};
		
		int num = 0;
		String a = h.substring(0, 1);
		String b = h.substring(1, 2);
		for(int i=0; i<rigid.length; i++){
			if(a.equals(rigid[i])){
				num += i * 16;
			}
			
			if(b.equals(rigid[i])){
				num += i;
			}
		}
		
		return num;
	}
}

Measured memory_bytes: 9832
#include <bits/stdc++.h>
using namespace std;
int a[150];
int main()
{
	int n,x,count;
	cin >>n>>x;
	for (int i=1;i<=n;i++)
	cin >>a[i];
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)
	x=x-a[i];
	count=n+x/a[1];
	cout<<count;
	
} 

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		double[] p = new double[N];
		for(int i = 0; i < N; i++)
			p[i] = (double)(sc.nextInt()+1)/2;
		double[] sum = new double[N];
		sum[0] = p[0];
		for(int i = 1; i < N; i++) {
			sum[i] = sum[i-1];
			sum[i] += p[i];
		}
		double ans = sum[K-1];
		for(int i = K; i < N; i++)
			ans = Math.max(ans, sum[i]-sum[i-K]);
		System.out.println(ans);

	}

}


Measured memory_bytes: 72668
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int k; string s; cin >> k >> s;
  if(s.length() <= k) cout << s << endl;
  else cout << s.substr(0, k) << "..." << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;
using System.Xml;

namespace hello_world
{
	class Program
	{

		static void Main(string[] args)
		{
			string t = Console.ReadLine();
			string tt = t.Replace("P?", "PD");
			string ttt = tt.Replace("?P", "DP");
			string tttt = ttt.Replace("?", "D");
			Console.WriteLine(tttt);






		}
	}
}




Measured memory_bytes: 29936
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


string ans;
const int N =4;
int in[N];
int visit[N];

char calc[N-1];
int dat[N];

int cp(int a,int b,char c){
	if(c=='+')return a+b;
	if(c=='-')return a-b;
	return a*b;
}

void adans(const char* cp){
	string s = string(cp);
	//cout<<s<<endl;
	ans = s;
}

void solve3(){
	char sp[11111];
	if(cp(cp(cp(dat[0],dat[1],calc[0]),dat[2],calc[1]),dat[3],calc[2])==10 ){
		sprintf(sp,"((%d %c %d) %c %d) %c %d",dat[0],calc[0],dat[1],calc[1],dat[2],calc[2],dat[3]);
		adans(sp);
	}
	if(cp(cp(dat[0],dat[1],calc[0]),cp(dat[2],dat[3],calc[2]),calc[1])==10  ){
		sprintf(sp,"(%d %c %d) %c (%d %c %d)",dat[0],calc[0],dat[1],calc[1],dat[2],calc[2],dat[3]);
		adans(sp);
	}
	if(cp(cp(dat[0],cp(dat[1],dat[2],calc[1]),calc[0]),dat[3],calc[2])==10  ){
		sprintf(sp,"(%d %c (%d %c %d)) %c %d",dat[0],calc[0],dat[1],calc[1],dat[2],calc[2],dat[3]);
		adans(sp);
	}
	if(cp(dat[0],cp(cp(dat[1],dat[2],calc[1]),dat[3],calc[2]),calc[0])==10  ){
		sprintf(sp,"%d %c ((%d %c %d) %c %d)",dat[0],calc[0],dat[1],calc[1],dat[2],calc[2],dat[3]);
		adans(sp);
	}
	if(cp(dat[0],cp(dat[1],cp(dat[2],dat[3],calc[2]),calc[1]),calc[0])==10  ){
		sprintf(sp,"%d %c (%d %c (%d %c %d))",dat[0],calc[0],dat[1],calc[1],dat[2],calc[2],dat[3]);
		adans(sp);
	}
}

void solve2(int depth){
	if(depth==N-1){
		solve3();
		return;
	}
	char cc[3]={'+','-','*'};
	rep(i,3){
		calc[depth]=cc[i];
		solve2(depth+1);
	}
}

void solve(int depth){
	if(depth==N){
		rep(i,N){
			dat[visit[i]]=in[i];
		}
		solve2(0);
		return;
	}
	
	rep(i,N){
		if(visit[i]==-1){
			visit[i]=depth;
			solve(depth+1);
			visit[i]=-1;
		}
	}
}
int main(){
	
	while(1){
		cin>>in[0]>>in[1]>>in[2]>>in[3];
		if(in[0]==0 && in[1]==0 && in[2]==0 && in[3]==0)break;
		
		ans = "0";
		rep(i,N)visit[i]=-1;
		
		solve(0);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1244
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	int a[5], h[4] = { 0 };
	cin >> a[0];
	h[a[0]]++;
	while (a[0]){
		for (int i = 1; i < 5; i++){
			cin >> a[i];
			h[a[i]]++;
		}
		if ((h[1] && h[2] && h[3]) || (h[1] == 5 || h[2] == 5 || h[3] == 5)){
			for (int i = 0; i < 5; i++){
				cout << 3 << endl;
			}
		} else {
			if (h[1] == 0){
				for (int i = 0; i < 5; i++){
					if (a[i] == 2){
						cout << 1 << endl;
					} else{
						cout << 2 << endl;
					}
				}
			} else if (h[2] == 0){
				for (int i = 0; i < 5; i++){
					if (a[i] == 3){
						cout << 1 << endl;
					} else{
						cout << 2 << endl;
					}
				}
			} else {
				for (int i = 0; i < 5; i++){
					if (a[i] == 1){
						cout << 1 << endl;
					} else{
						cout << 2 << endl;
					}
				}
			}
		}
		for (int i = 0; i < 5; i++){
			a[i] = 0;
		}
		for (int i = 1; i < 4; i++){
			h[i] = 0;
		}
		cin >> a[0];
		h[a[0]]++;
	}
	return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);


	int a,b,c;
	cin >> a >> b >>c;

	cout << max(max(a, b), c) - min(min(a, b), c) << endl;
	/*
	vector<int> data(s);
	rep(i, 0, s) {
		cin >> data[i];

	}
	/*int min = 1;
	rep(i, 0, s) {

		min = lcm(min, data[i]);
	}

	min -= 1;

	int ans = 0;

	rep(i, 0, s) {

		ans += data[i] - 1;;
	}

	cout << ans << endl; */


}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int L, R, d;
	scanf("%d%d%d", &L, &R, &d);
	printf("%d\n", R / d - L / d + (L % d == 0));
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

string s;
i64 K;


int main(){
  cin >> s >> K;
  for(int i = 0;i < s.size() && i < K - 1;i++){
    if(s[i] != '1'){
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << s[K - 1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;




int main() {

	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);


	char x; cin >> x;
	if (x >= 'a'&&x <= 'z')cout << 'a' << endl;
	else cout << 'A' << endl;





	return 0;
}


Measured memory_bytes: 3556
#include<cstdio>

using namespace std;

int main(){
	for(int n,r;scanf("%d%d",&n,&r),n;){
		int p[50],c[50],i;
		for(i=0;i<r;i++) scanf("%d%d",p+i,c+i);

		int q=0;
		for(i=r-1;i>=0;i--){
			if     (q<c[i])        q+=p[i]-1;
			else if(q<c[i]+p[i]-1) q-=c[i];
		}
		printf("%d\n",n-q);
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int x,y,z;
  cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y;

  return 0;
}


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

#define N 100

int main(){
  int G[N][N],n,u,v,k,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
      for(j=0;j<n;j++){
          G[i][j]=0;
      }
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[i][v-1]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
        printf("%d",G[i][j]);
      if(j<n-1) printf(" ");
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int a = 0, b = 0, c = 0;
	cin >> n;
	if(n / 100 == 1)
		a = 9;
	if(n / 10 - (n / 100) * 10 == 1)
		b = 9;
	if(n % 10 == 1)
		c = 9;
	if(n / 100 == 9)
		a = 1;
	if(n / 10 - (n / 100) * 10 == 9)
		b = 1;
	if(n % 10 == 9)
		c = 1;
	cout << a << b << c;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100
void print(int A[],int n){
		for(int i=0;i<n;i++){
			if(i>0)
				cout<<" ";
			cout<<A[i];	
		}
		cout<<endl;	
}
int main(){
	int n,A[MAX],k=0,j,minj,temp;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>A[i];

	for(int i=0;i<n;i++){
		minj=i;
		for(j=i+1;j<n;j++){
			if(A[j]<A[minj]){
				minj=j;
			}
		}
		temp=A[minj];
		A[minj]=A[i];
		A[i]=temp;
		if(i!=minj)k++;
	}
	print(A,n);
	cout<<k<<endl;
	return 0;
}


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

#define ll long long int

int main() {
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll m=arr[0];
    ll ans=0;
    for(ll i=1;i<n;i++)
    {
        if(arr[i]>m)
        {
            m=arr[i];
        }
        else
        {
            ans+=(m-arr[i]);
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 5136
#include<bits/stdc++.h>
#define taskname "test1"
#define int long long
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);	cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int n, x, y;    cin >> n >> x >> y;
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        int hold = 0;
        for (int j = i; j; j /= 10) hold += j % 10;
        if (hold >= x && hold <= y) ans += i;
    }
    cout << ans;
}



Measured memory_bytes: 256
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

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

/*
    zet:
        find_by_order(k): k-stat [k > 0]
        order_of_key(k) : {el < k}

    gp_hash_table<key, val, custom_hash>

    rope<T>:
        iterators: mutable_begin, ..
        methods  : erase, insert, substr, ..
*/

#define all(x) (x).begin(), (x).end()
#define size(x) (int)((x).size())
#define em_back emplace_back

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<typename T>
using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 eng(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int n;
    ll res = 0;
    cin >> n;
    int last = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;

        if (a == 0) {
            last = 0;
            continue;
        } else {
            if (last) {
                ++res;
                --a;
                last = a % 2;
                res += a / 2;
            } else {
                last = a % 2;
                res += a / 2;
            }
        }
    }
    cout << res << "\n";
}

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

    int z = 1;
    /// cin >> z;

    while (z--) {
        solve();
    }

    return 0;
}


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

using namespace std;

struct node
{
	int num,ls,rs;
	node(int _num)
	{
		num=_num;
		ls=-1;
		rs=-1;
	}
};

typedef vector<node> Tree;

Tree T;

void insert(int t,int n)
{
	
	if(T.size()==0)
		T.push_back(node(n));
	else if(T[t].num>n)
		if(T[t].ls==-1)
		{
			T[t].ls=T.size();
			T.push_back(node(n));
		}
		else insert(T[t].ls,n);
	else
		if(T[t].rs==-1)
		{
			T[t].rs=T.size();
			T.push_back(node(n));
		}
		else insert(T[t].rs,n);
}

void find(int t,int x)
{
	if(T.size()==0||t==-1)
		printf("no\n");
	else if(T[t].num==x)
		printf("yes\n");
	else if(x<T[t].num)
		find(T[t].ls,x);
	else find(T[t].rs,x);
}

void Preorder(int t)
{
	if(t==-1) return;
	printf(" %d",T[t].num);
	Preorder(T[t].ls);
	Preorder(T[t].rs);
}

void Inorder(int t)
{
	if(t==-1) return;
	Inorder(T[t].ls);
	printf(" %d",T[t].num);
	Inorder(T[t].rs);
}

void print()
{
	Inorder(0);
	printf("\n");
	Preorder(0);
	printf("\n");
}

int main()
{
	int n;
	scanf("%d",&n);
	while(n--)
	{
		char s[10];
		scanf("%s",s);
		if(s[0]=='i')
		{
			int t;
			scanf("%d",&t);
			insert(0,t);
		}
		else if(s[0]=='f')
		{
			int t;
			scanf("%d",&t);
			find(0,t);
		}
		else print();
	}
}

Measured memory_bytes: 9032
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m;
    cin>>n>>m;
    if(n==0)
    {
        if(m==100)
        {
            m=101;
        }
        cout<<m<<endl;
    }
    else if(n==1)
    {
        if(m==100)
        {
            cout<<m*100+100<<endl;
        }
        else
        {
            cout<<m*100<<endl;
        }
    }
    else if(n==2)
    {
        if(m==100)
        {
            cout<<m*10000+10000<<endl;
        }
        else
        {
            cout<<m*10000<<endl;
        }
    }
    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N, K;

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

    int cnt = 0;
    rep(i, N){
        int x = i + 1;
        if(x % K == 0) cnt++;
    }

    ll ans = (ll) cnt * cnt * cnt;

    if(K % 2 == 0){
        cnt = 0;
        rep(i, N){
            int x = i + 1;
            if(x % (K / 2) == 0 && x % K != 0) cnt++;
        }
        ans += (ll) cnt * cnt * cnt;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pll;

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
const int N = 3005;
int dp[N][N];
int a[N];

int func(int l,int r){
	if(dp[l][r] != 0)	return dp[l][r];
	if(r-l == 0)	return dp[l][r] = a[l];
	if(r-l == 1)	return dp[l][r] = max(a[l],a[r]);
	return dp[l][r] = 
		max(min(func(l+2,r), func(l+1,r-1)) + a[l],min(func(l+1,r-1),func(l,r-2)) + a[r]);
}

signed main(){
	IOS
	int n;	cin >> n;
	int sum = 0;
	rep(i,n)	cin >> a[i],sum += a[i];
	cout << func(0,n-1)*2 - sum << endl;


}


Measured memory_bytes: 70144
# coding: utf-8
# Your code here!

# 7で割り切れる数かを検証するということは1 ~ kで割ると良い
# ただし、毎回10をかけて7を足していると計算できない範囲まで大きくなるので毎回kで割ったあまりを用いる

k = int(input())

num = 7
if k == 1 or k == 7:
    print(1)
    exit()
for i in range(1, k + 1):
    num = num * 10 + 7
    if num % k == 0:
        print(i + 1)
        exit()
    else:
        num %= k
        
print(-1)
exit()


Measured memory_bytes: 9180
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math
 
#import bisect
 
def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result
 
def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta
 
def main():
#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
    n=int(input())
    s=list(map(int,input()))
    c = [[-2 for j in range(11)] for i in range(10)]
    d={0}
 #   print(c)
 
    for i in range(n):
        for j in range(10):
            if c[j][10] > -2:
                for k in range(10):
                    if c[j][k]>-2:
                        d.add(str(j)+str(k)+str(s[i]))
                c[j][s[i]]=-1
        c[s[i]][10] = -1
#    print(d)
 
 #   print(c)
    for i in range(100):
        d.discard(str(i))
    d.discard(0)
#    print(d)
    print(len(d))
            #    print(n,kingaku(a,b,x))
 
if __name__ == "__main__":
    main()

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    ll N;
    cin >> N;
    string ans = "";
    while(N){
        N--;
        ans += 'a' + N % 26;
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  string S[H*W];
  
  char ans_c = 'A';
  int ans_i = 0; 
  
  for(int i = 0; i < H*W; i++){
  	cin >> S[i];
    if(S[i] == "snuke"){
    	ans_c += i % W;
      	ans_i = (i - (i % W) ) / W ;
      	break;
    }
  }
  
  cout << ans_c << ans_i + 1 << endl;
}

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

int main(){
    double D,T,S;
    cin >> D >> T >> S;

    if(D/S<=T){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  //int A, B, C, X, Y;
//  int m[101]={};
  long long min=0;
  int A, B, C, K;
//  int sosu[20000]={};
  int i,j,k;
  int flag=0;  
//    int k=0;

  scanf("%d", &A);
  //printf("%d\n", A);

   if(A<1000)   printf("ABC\n");
   else   printf("ABD\n");

return 0;
}


Measured memory_bytes: 128
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#define rep(i,n) for (int i = 0; i < (n);i++)
typedef long long ll;
using namespace std;
/*#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;*/


void Main()
{
	int n; cin>>n;
	vector<int> p(n);
	rep(i,n) {
		cin>>p.at(i);
	}
  int count =0;
  rep(i,n-2) {
    if(p.at(i)<p.at(i+1) && p.at(i+1) < p.at(i+2))
      count++;
    else if(p.at(i)>p.at(i+1) && p.at(i+1)>p.at(i+2))
      count++;
  }
  cout << count << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    long long n,m,AC=0LL,WA=0LL;
    cin>>n>>m;
    vector<pair<long long,string>>data(m);
    bool ac[n];
    int wa[n];
    for(long long i=0;i<n;i++)ac[i]=false,wa[i]=0;
    for(long long i=0;i<m;i++){cin>>data[i].first>>data[i].second;data[i].first--;}
    for(long long i=0;i<m;i++){
        if(ac[data[i].first]==false){
            if(data[i].second=="AC"){
                ac[data[i].first]=true;
            }
            else wa[data[i].first]++;
        }
    }
    for(int i=0;i<n;i++){
        if(ac[i]==true){
            AC++;
            WA+=wa[i];
        }
    }
    cout<<AC<<" "<<WA<<endl;
    return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int h, w;
    std::cin>>h>>w;
    std::vector<std::string> s(h);
    for(int i = 0; i < h;i++){
        std::cin>>s[i];
    }

    int cnt = 0;
    for(int i = 1;i < h - 1;i++){
        for(int j = 1;j < w - 1;j++){
            if(s[i][j] == '#' && s[i-1][j] == '.' &&
                    s[i][j-1] == '.' && s[i][j+1] == '.' &&
                    s[i+1][j] == '.'){
                ++cnt;
            }
        }
    }
    if(s[0][0] == '#' && s[1][0] == '.' && s[0][1] == '.'){
        ++cnt;
    }
    if(s[0][w-1] == '#' && s[0][w-2] == '.' && s[1][w-1] == '.'){
        ++cnt;
    }
    if(s[h-1][0] == '#' && s[h-2][0] == '.' && s[h-1][1] == '.'){
        ++cnt;
    }
    if(s[h-1][w-1] == '#' && s[h-1][w-2] == '.' && s[h-2][w-1] == '.'){
        ++cnt;
    }
    std::cout<<(cnt == 0 ? "Yes" : "No")<<std::endl;
    return 0;
}

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

int main()
{
	long long N;
	scanf("%lld", &N);
	
	long long n, max = 1;
	for (n = 2; n * n <= N; n++) {
		if (N / n * n == N) max = n;
	}
	
	int d;
	for (d = 0, n = N / max; n > 0; d++, n /= 10);
	
	printf("%d\n", d);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
use std::io::stdin;

fn main() {
    let mut aaaa = String::new();
    stdin().read_line(&mut aaaa).unwrap();
    let nx: Vec<usize> = aaaa.trim().split_whitespace().flat_map(str::parse).collect();
    let (w, h, x, y) = (nx[0], nx[1], nx[2], nx[3]);

    match (x * 2 == w, y * 2 == h) {
        (true, true) => println!("{:.9} 1", w as f64 * h as f64 / 2f64),
        _ => println!("{:.9} 0", w as f64 * h as f64 / 2f64),
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
 
int main(){
	int a;
	while(scanf("%d", &a) != EOF){
		if(a % 39 == 0) printf("3C%d\n", 39);
		else if(a % 39 < 10) printf("3C0%d\n", a % 39);
		else printf("3C%d\n", a % 39);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define pb push_back
#define log(x,b) (log(b)/log(x))
#define rep(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;

const int mod=1e9+7;

int32_t main()
{
    int n,k;
    cin>>n>>k;
    map<int,int>mp;
    rep(i,0,n){
        int a,b;
        cin>>a>>b;
        mp[a]+=b;
    }
    for(auto val:mp){
        if(val.second>=k){
            cout<<val.first<<endl;
            return 0;
        }
        else k-=val.second;
    }
    return 0;
}


Measured memory_bytes: 7524
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp,x,y;
string str;
set<ll> s;
map<pll,vector<pll>> v;
ll bfs(pll root)
{
    queue<pll> q;
    q.push(root);
    map<pll,bool> vis;
    vis[root]=1;
    map<pll,ll> level;
    level[root]=0;
    ll mx=0;
    while(!q.empty())
    {
        pll f=q.front();
        q.pop();
        for(auto x:v[f])
        {
            if(!vis[x])
            {
                vis[x]=1;
                level[x]=level[f]+1;
                mx=max(mx,level[x]);
                q.push(x);
            }
        }
    }
    level.clear();
    vis.clear();
    return mx;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	if(n==1 || m==1)
	{
	    cout<<max(n-1,m-1);
	    return 0;
	}
	string s[n+10];
	for(int i=0;i<n;i++)
	cin>>s[i];
	for(int i=0;i<n;i++)
	{
	    for(int j=0;j<m;j++)
	    {
	        if(s[i][j]=='#')
	        continue;
	        if(j!=0 && j!=m-1)
	        {
	           if(s[i][j+1]=='.')
	           v[{i,j}].pb({i,j+1});
	           if(s[i][j-1]=='.')
	           v[{i,j}].pb({i,j-1});
	        }
	        if(j==0)
	        {
	            if(s[i][j+1]=='.')
	            v[{i,j}].pb({i,j+1});
	        }
	        if(j==m-1)
	        {
	            if(s[i][j-1]=='.')
	            {v[{i,j}].pb({i,j-1});}
	        }
	        if(i!=0 && i!=n-1)
	        {
	           if(s[i-1][j]=='.')
	           v[{i,j}].pb({i-1,j});
	           if(s[i+1][j]=='.')
	           v[{i,j}].pb({i+1,j});
	        }
	        if(i==0)
	        {
	            if(s[i+1][j]=='.')
	            v[{i,j}].pb({i+1,j});
	        }
	        if(i==n-1)
	        {
	            if(s[i-1][j]=='.')
	            v[{i,j}].pb({i-1,j});
	        }
	    }
	}
	ll ans=0;
// 	for(auto x:v[{0,4}])
// 	{
// 	    cout<<x.fi<<' '<<x.se;
// 	    nl;
// 	}
	for(int i=0;i<n;i++)
	{
	    for(int j=0;j<m;j++)
	    {
	        if(s[i][j]=='#')
	        continue;
	        ans=max(bfs({i,j}),ans);
	    }
	}
	cout<<ans;
	
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
typedef long double ld;
using namespace std;
//-------------------------------------------------------------------
ll M=1;
std::vector<ll> W, B;
void init(int N){
  while(M<N) M*=2;
  M=M*2-1;
  for(int i=0;i<M;i++) {
    W.push_back(0);
    B.push_back(0);
  }
}
void update(int l, int r, int k, int mode){
  k+=(M+1)/2-1;
  (mode==1?W[k]:B[k])++;
  while(k>0){
    k = (k-1)/2;
    (mode==1?W[k]:B[k]) = (mode==1?W[k*2+1]+W[k*2+2]:B[k*2+1]+B[k*2+2]);
  }
}
ll query(int a, int b, int l, int r, int k, int mode){
  if(r<=a || b<=l) return 0;
  if(a<=l && r<=b) return (mode==1?W[k]:B[k]);
  ll A = query(a, b, l, (l+r)/2, k*2+1, mode);
  ll B = query(a, b, (l+r)/2, r, k*2+2, mode);
  return A + B;
}
//-------------------------------------------------------------------

int main(int argc, char const *argv[]) {
  ll N, a, INF = 1000000007;
  char c;
  std::cin >> N;
  init(N+1);
  vvl big_w = vv(N+1, N+2, 0, ll);
  vvl big_b = vv(N+1, N+2, 0, ll);
  for(ll i=1;i<=2*N;i++){
    std::cin >> c >> a;
    ll tmp = query(a+1, (M+1)/2, 0, (M+1)/2, 0, (c=='W'?1:-1));
    for(int j=0;j<=N+1;j++){
      if(j==N+1) (c=='W'?big_w[a][j]:big_b[a][j]) = tmp;
      else (c=='W'?big_w[a][j]:big_b[a][j]) = tmp + query(j, (M+1)/2, 0, (M+1)/2, 0, (c=='W'?-1:1));
    }

    update(0, (M+1)/2, a, (c=='W'?1:-1));
  }
  vvl dp = vv(N+1, N+1, 0, ll);
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      if(i==0&&j==0) continue;
      dp[i][j] = min((i==0?INF:dp[i-1][j]+big_w[i][j+1]),(j==0?INF:dp[i][j-1]+big_b[j][i+1]));
    }
  }
  /*
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++) std::cout << dp[i][j] << " ";
    std::cout << '\n';
  }*/

  std::cout << dp[N][N] << '\n';
  return 0;
}


Measured memory_bytes: 94464
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
	ll n,l; cin >> n >> l;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	ll ma=0;
	int cp=-1;
	for(int i=0;i<n-1;i++){
		ma=max(ma,a[i]+a[i+1]);
		if(ma==a[i]+a[i+1])cp=i+1;
	}
	if(ma<l){
		cout << "Impossible" << endl;
		return 0;
	}
	else{
		cout << "Possible" << endl;
		for(int i=1;i<cp;i++){
			cout << i << endl;
		}
		for(int i=n-1;i>cp;i--){
			cout << i << endl;
		}
		cout << cp << endl;
	}
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
vector< vector<int> > G(10001);
queue<int> que;
int n_v, n_e, u, v;
int in_degree[10001], ans[10001], idx;


int main(){

    memset(in_degree, 0, sizeof(in_degree));
    scanf("%d %d", &n_v, &n_e);
    for(int i=0; i<n_e; i++){
        scanf("%d %d", &u, &v);
        G[u].push_back(v);
        in_degree[v] += 1;
    }

    idx = 0;
    for(int i=0; i<n_v; i++) 
        if(in_degree[i]==0){
            ans[idx++] = i;
            que.push(i);     
        }

    while(!que.empty()){
        u = que.front();
        que.pop();
        for(int i=0; i<G[u].size(); i++){
            v = G[u][i];
            in_degree[v] -= 1;
            if(in_degree[v]==0){
                ans[idx++] = v;
                que.push(v);
            }
        }
    }
    for(int i=0; i<n_v; i++)
        printf("%d\n", ans[i]);
    return 0;
}


Measured memory_bytes: 3240
from collections import deque
from fractions import gcd
import functools
n, x = map(int, input().split())
xl = list(map(int, input().split()))

xl.append(x)
xl.sort()

l = deque()
for i in range(n):
    l.append(xl[i+1] - xl[i])

l = list(set(l))
ans = functools.reduce(gcd, l)
print(ans)

Measured memory_bytes: 88300
#include <bits/stdc++.h>
     
    using namespace std;
     
    int mod=1e9+7;  ///A simpler way to write 1,000,000,007
     
    int main()
    {
        int n,k;
        cin >> n >> k;
        int a[n+1];
        for(int i=1;i<=n;i++)
        {
            cin >> a[i];
        }
        int dp[n+1][k+1];
        dp[0][0]=1;
        for(int i=1;i<=k;i++)  /// Set the initial values
        {
            dp[0][i]=0;
        }
        for(int i=1;i<=n;i++)
        {
            int sums[k+1];
            sums[0]=dp[i-1][0];
            for(int j=1;j<=k;j++)
            {
                sums[j]=(sums[j-1]+dp[i-1][j])%mod;  ///Calculate the prefix sums for i-1
            }
            for(int j=0;j<=k;j++)
            {
                int tr=sums[j];  ///Sum of dp[i-1][0...j]
                int unreachable=j-a[i]-1;  ///We need to subtract the sum of the first "unreachable" elements (dp[i-1][0...unreachable])
                if(unreachable>=0)
                {
                    tr=(tr-sums[unreachable]+mod)%mod;  ///Add mod to make sure that "tr-sums[unreachable]" is not negative.
                }
                dp[i][j]=tr;
            }
        }
        cout << dp[n][k];
        return 0;
    }

Measured memory_bytes: 40064
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
//    long long L,R;
//    cin >> L >> R;
//
//    long long ans = 0;
//    long long L_by_2019 = L / 2019;
//    long long R_by_2019 = R / 2019;
//    long long L_mod_2019 = L % 2019;
//    long long R_mod_2019 = R % 2019;
//    if (L_by_2019 != R_by_2019) {
//        ans = 0;
//    }
//    else{
//        ans = L_mod_2019 * (L_mod_2019+1);
//    }
//    ans = ans % 2019;
//    cout << ans << endl;
    
    int N, A, B;
    cin >> N >> A >> B;
    if (N*A < B) {
        cout << N * A << endl;
    }
    else{
        cout << B << endl;
    }
}


Measured memory_bytes: 256
n,m=map(int, input().split()) 
x=list(map(int, input().split()))
x.sort()
x.reverse()
v=[]
for i in range(m-1):
    v.append(x[i]-x[i+1])
v.sort()
v.reverse()
del v[:n-1]
print(sum(v))

Measured memory_bytes: 14096
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

s = ins()
if s=='ab':
    3/0
n = len(s)
if s[0]==s[-1]:
    n += 1
print('Second' if n%2==0 else 'First')


Measured memory_bytes: 62608