akhauriyash/Code-Regression huggingface dataset:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  ans=[-1]*n

  f=False
  for i in range(m):
    a,b=LI()
    a-=1
    if ans[a]!=-1:
      if ans[a]!=b:
        f=True
    else:
      ans[a]=b

  if f:
    return -1

  _ans=''
  for i,x in enumerate(ans):
    if x==-1:
      if i==0 and n!=1:
        _ans+='1'
      else:
        _ans+='0'
    else:
      _ans+=str(x)

  __ans=int(_ans)
  if len(str(__ans))<n:
    return -1

  return _ans

# main()
print(main())


Measured memory_bytes: 5588
import math
A,B=map(int,input().split())
c=lambda x,y:set(range(math.ceil(x/y),int((x+1)/y)))
a=c(A,0.08)
b=c(B,0.1)
s=a&b
print(min(a&b) if len(s)>0 else -1)

Measured memory_bytes: 3188
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextLong
  val a = sc.nextLong
  val b = sc.nextLong

  val res =
    if((b - a ) % 2 == 0) (b - a) / 2
    else Math.min( (a + b - 1) / 2, (2 * n - a - b + 1) / 2 )

  println(res)
}

Measured memory_bytes: 25756
#include<bits/stdc++.h>
#define N 100005
using namespace std;
map<int,int>mp,s;
int n,a[N],b[N],cnt;
int f[N],siz[N],ss[N];
int find(int x)
{
    if(x==f[x])return x;
    return f[x]=find(f[x]);
}
void add(int a,int b)
{
    int aa=find(a),bb=find(b);
    if(aa!=bb)
    {
        f[aa]=bb;
        siz[bb]+=siz[aa];
        ss[bb]+=ss[aa];
    }ss[bb]++;
}
int main()
{
    scanf("%d",&n);int sum=0,fl=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        sum^=a[i];
        mp[a[i]]++;
    }
    //cout<<sum<<endl;
    for(int i=1;i<=n;i++)
    {
       // if(sum==a[i]&&mp[a[i]]==1)continue;
        if(s[a[i]]!=0)continue;
        s[a[i]]=++cnt;f[cnt]=cnt;siz[cnt]=mp[a[i]];
    }
    if(mp.find(sum)!=mp.end())mp[sum]++;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&b[i]);
        if(b[i]==a[i])siz[find(s[a[i]])]--;
        if(mp.find(b[i])==mp.end())
        {
            if(!fl&&b[i]==sum)fl=1;
            else return puts("-1"),0;
        }
        else
        {
            //cout<<mp[b[i]]<<endl;
            if(!fl&&b[i]==sum)fl=1;
            else if(mp[b[i]]==0)return puts("-1"),0;
            if(mp[b[i]]!=0)mp[b[i]]--,add(s[b[i]],s[a[i]]);
        }
    }
    int ans=0;
    for(int i=1;i<=cnt;i++)
    {
        if(find(i)==i)
        {
            if(siz[i]==0)continue;
            ans+=siz[i]+1;
        }
    }
    if(fl&&ans)ans--;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, W; cin >> N >> W;
  vector<vector<long long>> dp(N + 1, vector<long long>(W + 1));
  for (int i = 0; i < N; ++i)
    {int w, v; cin >> w >> v;
    for (int j = 0; j <= W; ++j)
      {dp[i + 1][j] = max(dp[i][j], j < w ? 0 : dp[i][j - w] + v);}}
  cout << dp[N][W] << endl;}

Measured memory_bytes: 80256
using System;
using System.Collections.Generic;
using System.Linq;

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var rs = Enumerable.Range(0, h[1]).Select(i => read()).Select(r => new R { A = r[0], B = r[1], C = r[2] - h[2] }).ToArray();
		map = rs.GroupBy(r => r.A).ToDictionary(g => g.Key, g => g.ToArray());

		var cs = Enumerable.Repeat(long.MinValue, h[0] + 1).ToArray();
		cs[1] = 0;
		long c;
		for (var i = 0; i < h[0]; i++)
			foreach (var r in rs)
				if (cs[r.A] != long.MinValue && cs[r.B] < (c = cs[r.A] + r.C)) cs[r.B] = c;

		foreach (var r in rs)
		{
			if (ups.Contains(r.B) || cs[r.A] == long.MinValue || cs[r.B] >= cs[r.A] + r.C) continue;
			FindPath(r.B);
			if (ups.Contains(h[0])) { Console.WriteLine(-1); return; }
		}
		Console.WriteLine(Math.Max(cs[h[0]], 0));
	}

	static Dictionary<int, R[]> map;
	static HashSet<int> ups = new HashSet<int>();

	static void FindPath(int p)
	{
		if (ups.Add(p) && map.ContainsKey(p)) foreach (var r in map[p]) FindPath(r.B);
	}
}

struct R
{
	public int A, B, C;
}


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

int main() {
  
  int N;
  cin >> N;
  vector<string> blue(N);
  for(int i=0; i<N; i++){
    cin >> blue.at(i);
  }
  int M;
  cin >> M;
  vector<string> red(M);
  for(int i=0; i<M; i++){
    cin >> red.at(i);
  }
  
  int f=0,s=0;
  
  for(int i=0; i<N; i++){
    
    for(int j=0; j<N; j++){
      if(blue.at(i)==blue.at(j)){
        s++;
      }
    }
    for(int j=0; j<M; j++){
      if(blue.at(i)==red.at(j)){
        s--;
      }
    }
    
    if(s>f){
      f=s;
    }
    s=0;
  }
  cout << f << endl;
}



Measured memory_bytes: 256
#include <iostream>

int main()
{
	int a;
	std::cin >> a;
	int b = a / 1000;
	int c = a % 1000;
	int d = c / 100;
	int e = c % 100;
	int f = e / 10;
	int g = e % 10;
	if (b == d &&d== f) {
		std::cout << "Yes" << std::endl;
	}
	else if (d == f&&f == g) {
		std::cout << "Yes" << std::endl;
	}
	else if (b == d && d == f&&f == g) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
    return 0;
}


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

using namespace std;

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;

#define INF (1e9)

// テンプレート関数
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)

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

    if (K == 1) {
        ans = 0;
    } else {
        ans = N - K;
    }

    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

/*should use ::toupper/lower as its defined in global scope, not std*/

#define pb push_back
#define eb emplace_back
#define res reserve

#define pii pair<int, int>
#define mp make_pair
#define f first
#define s second

#define pq priority_queue<int, vector<int>, greater<int>>

#define mt make_tuple

#define endl << "\n" 
#define bigint __int128_t; // Not available in all contest systems
#define rr return
#define cc continue

#define feq(a, b) (abs(a - b) < 1e-9)

using ll = long long;

using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

#define madd(a, b) ((int(a) % MOD + int(b) % MOD) % MOD)
#define msub(a, b) ((int(a) % MOD - int(b) % MOD) % MOD)
#define mmul(a, b) ((int(a) % MOD * int(b) % MOD) % MOD)

#define ue(u, v, g) g[u].eb(v), g[v].eb(u)

const int mxN = (int)1e7 + 10000;

void solve() {

	double a, b;
	cin >> a >> b;

	double h, m;
	cin >> h>> m;

	double beta = 6*m;
	double alpha = 30 * h + (0.5 * m);

	double diff = abs(beta - alpha);

	diff = min(diff, 360 - diff);

	diff = diff * acos(-1) / 180.0;
	cout << setprecision(15) << (double) sqrt(a*a + b*b - (2 * a * b * cos(diff)));


}

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int t;
	//cin >> t;
	t = 1;

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

}

Measured memory_bytes: 4304
#!/usr/bin/python3
import sys
from collections import Counter
input = lambda: sys.stdin.readline().strip()
n, p = [int(x) for x in input().split()]
s = input()
ans = 0
if p == 2 or p == 5:
    allowed_digits = '24680' if p == 2 else '50'
    for i, c in enumerate(s, start=1):
        if c in allowed_digits:
            ans += i
else:
    def minv(x, p):
        return pow(x, p - 2, p)

    count = Counter({0: 1})
    x, delta = 0, 1
    for c in s:
        x = ((x * 10) + ord(c) - ord('0')) % p
        y = (x * minv(delta, p)) % p
        ans += count[y]
        count[y] += 1
        delta = (delta * 10) % p

print(ans)


Measured memory_bytes: 10060
using System;

namespace Application
{
    class MainClass
    {
        static int n;
        static int[] x;
        static int[] y;

        public static void Main(string[] args)
        {
            n = int.Parse(Console.ReadLine());
            x = new int[n];
            y = new int[n];

            for (int i = 0; i < n; i++)
            {
                var xy = Console.ReadLine().Split();
                x[i] = int.Parse(xy[0]);
                y[i] = int.Parse(xy[1]);
            }

            var sum = 0.0;
            for (int i = 0; i < n; i++)
            {
                var v = new bool[n];
                v[i] = true;
                sum += dfs(i, 0, v);
            }

            var ans = sum / fact(n);
            Console.WriteLine(ans);
        }

        static long fact(long n)
        {
            var ans = 1L;
            for (int i = 2; i <= n; i++)
            {
                ans *= i;
            }
            return ans;
        }

        static double dfs(int p, double a, bool[] v)
        {
            var all = true;
            for (int i = 0; i < n; i++) all &= v[i];
            if (all) return a;

            var sum = 0.0;
            for (int q = 0; q < n; q++)
            {
                if (v[q]) continue;
                v[q] = true;
                sum += dfs(q, a + distans(p, q), v);
                v[q] = false;
            }
            return sum;
        }

        static double distans(int a, int b)
        {
            return m1(x[a], y[a], x[b], y[b]);
        }

        static double m1(int x1, int y1, int x2, int y2)
        {
            var ax = x1 - x2;
            var ay = y1 - y2;
            return Math.Sqrt(ax * ax + ay * ay);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

void test();

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<pair<ll, ll>> a(n);
	f(i,0,n){
		cin >> a[i].S >> a[i].F;
		// a[i].F = a[i].S.S - a[i].S.F;
	}
	sort(all(a));
	// for(auto el : a){
	// 	cout << el.F << " "<< el.S<< "\n";
	// }
	ll prev = 0;
	f(i,0,n){
		// cout << prev<<"\n";
		if(a[i].F-a[i].S < prev){
			cout << "No\n";
			return 0;
		}
		prev = prev+a[i].S;
	}
	cout << "Yes\n";
	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;
	if (A > B) swap(A, B);
	if ((B - A) <= T * (V-W)) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3656
#include<iostream>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;

    int max_num = A > B ? A : B;
    int min_num = A < B ? A : B;

    int sa = max_num - min_num;

    int ans;

    if(sa % 2 == 0) {
        ans = max_num - sa / 2;
    } else {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define MOD 1000000007

int N, K;
ll ans;
vector<int> G[100000];

ll fact[100001], fact_i[100001];

ll power(int x, int y) {
    if (y == 1) return x;
    ll p = power(x, y >> 1);
    if (y & 1) return p * p % MOD * x % MOD;
    else return p * p % MOD;
}

ll inv(ll n) {
    return power(n, MOD - 2);
}

void init(int n) {
    fact[0] = 1;
    REP(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_i[n] = inv(fact[n]);
    REP(i, n) fact_i[n - i - 1] = fact_i[n - i] * (n - i) % MOD;
}

ll nCr(ll n, ll r) {
    if (n < r || n < 0 || r < 0) return 0;
    return fact[n] * fact_i[r] % MOD * fact_i[n - r] % MOD;
}

void dfs(int v, int before) {
    int p = before == -1 ? 1 : 2;
    int c = G[v].size() - (before == -1 ? 0 : 1);
    if (c == 0) return;
    if (c + p > K) {
        ans = 0;
        return;
    }

    ans = ans * nCr(K - p, c) % MOD * fact[c] % MOD;
    for (int g : G[v]) if (g != before) dfs(g, v);
}

int main() {
    cin >> N >> K;
    init(100000);
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ans = K;
    dfs(0, -1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10752
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int tot = 0;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		tot += x != i;
	}
	if (tot <= 2) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define INF INT_MAX>>1 //要climits#includ

typedef long long ll;

using namespace std;


int main(void){
	int n, m; cin >> n >> m;
	static int a[100001];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a, a+n, greater<int>());
	static pair<long, long> cb[100001];
	for(int i=0; i<m; i++){
		cin >> cb[i].second >> cb[i].first;
	}
	sort(cb, cb+m, greater<pair<long, long> >());

	ll ans = 0;
	int s=0, t=0;
	for(int i=0; i<n; i++){
		if(a[s] > cb[t].first){
			ans += a[s];
			s++;
		} else{
			for(int j=0; j<cb[t].second; j++){
				if(i>=n) break;
				ans += cb[t].first;
				i++;
			}
			if(i>=n) break;
			i--;
			t++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  vector<int>vec;
  cin>>a>>b;
  vec.push_back(a);
  vec.push_back(b);
  cout<<6-vec.at(0)-vec.at(1)<<endl;
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define Maxn 200007
using namespace std;
int n,cnt=0;
int last[Maxn],other[Maxn],pre[Maxn];
int d[Maxn],dd[Maxn];
int u[Maxn],v[Maxn];
int p[Maxn],tot=0,size[Maxn];
int ans1[Maxn],ans2[Maxn];
bool check=true;
void insert(int u,int v)
{
	other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;
}
void dfs(int u,int fa)
{
	p[++tot]=u;
	int now=0;
	for (int q=last[u];q;q=pre[q])
	{
		int v=other[q];
		if (v!=fa&&d[v]!=1)
		{
			++now;
			dfs(v,u);
		}
	}
	if (now>1) check=false;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		scanf("%d%d",&u[i],&v[i]);
		++d[u[i]],++d[v[i]];
	}
	bool nowflag=false;
	for (int i=1;i<n;i++)
		if (d[u[i]]!=1&&d[v[i]]!=1)
		{
			insert(u[i],v[i]);
			insert(v[i],u[i]);
			++dd[u[i]];
			++dd[v[i]];
			nowflag=true;
		}
	if (n==2)
	{
		printf("%d %d\n",1,2);
		return 0;
	}
	int rt=0;
	for (int i=1;i<=n;i++)
		if (dd[i]==1) rt=i;
	if (rt!=0) dfs(rt,-1);
	if (!nowflag)
	{
		tot=1;
		for (int i=1;i<=n;i++)
			if (d[i]>1) p[1]=i;
	}
	if (!check) printf("%d\n",-1); else
	{
		memset(size,0,sizeof(size));
		if (!nowflag) size[1]=d[p[1]];
		else
		{
			for (int i=1;i<=tot;i++)
			{
				size[i]=d[p[i]]-1;
				if (i!=1&&i!=tot) --size[i];
			}
		}
		if (size[tot]>0)
		{
			--size[tot];
			++tot;
		}
		int anss=0;
		if (size[1]>0)
		{
			--size[1];
			ans1[++anss]=1;
		}
		for (int i=1;i<=tot;i++)
		{
			int now=anss+1;
			for (int j=1;j<=size[i];j++)
				ans1[++anss]=	anss+1;
			ans1[++anss]=now;
		}
		
		memset(size,0,sizeof(size));
		for (int i=1;i<tot+1-i;i++)
			swap(p[i],p[tot+1-i]);
		for (int i=1;i<=tot;i++)
		{
			size[i]=d[p[i]]-1;
			if (i!=1&&i!=tot) --size[i];
		}
		if (size[tot]>0)
		{
			--size[tot];
			++tot;
		}
		anss=0;
		if (size[1]>0)
		{
			--size[1];
			ans2[++anss]=1;
		}
		for (int i=1;i<=tot;i++)
		{
			int now=anss+1;
			for (int j=1;j<=size[i];j++)
				ans2[++anss]=	anss+1;
			ans2[++anss]=now;
		}
		bool flag=false;
		for (int i=1;i<=n;i++)
			if (ans1[i]<ans2[i])
			{
				flag=true;
				break;
			}
			else if (ans1[i]>ans2[i])
			{
				flag=false;
				break;
			}
		if (flag)
		{
			for (int i=1;i<=n;i++)
				ans2[i]=ans1[i];
		}
		for (int i=1;i<=n;i++)
			printf("%d ",ans2[i]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 12928
/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
vector<int>vi;
int n;
int main(){
	cin >> n;
	rep(i,n) { int a; cin >> a; vi.pb(a) ; }
	bool ok  =0 ;
	rep(i,n) rep(j,n){
		swap(vi[i],vi[j]);
		rep(x,n-1) if(vi[x] > vi[x+1]) goto fail;
		ok = 1; fail:;
		swap(vi[i],vi[j]);
	}
	puts(ok?"YES":"NO");
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n;
	int a[100000];
	int i;
	int flag = 0;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]%2 == 1){
			flag = 1;
		}
	}
	if(flag == 1){
		printf("first\n");
	}else{
		printf("second\n");
	}



	return 0;


}

Measured memory_bytes: 512
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define fr(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define triplet pair<int,pair<int,int>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

vector<int> tree[100001];
ll dp[100001][2];

ll solve(int u, bool constraint, int pr)
{
    if(dp[u][constraint] != -1)
        return dp[u][constraint];
    ll ans = 0;
    ll w1 = 1;
    for(int child : tree[u])
    {
        if(child != pr)
            w1 = (w1 * solve(child, 0, u)) % mod;
    }
    ans += w1;
    if(!constraint)
    {
     ll w2 = 1;
        for(int child : tree[u])
        {
            if(child != pr)
                w2 = (w2 * solve(child, 1, u)) % mod;
        }  
     ans = (ans + w2)%mod; 
    }
    return dp[u][constraint] = ans;
}

int main(){
    int n;
    cin>>n;
    memset(dp, -1, sizeof dp);
    for(int i=0; i < n-1; i++)
    {
        int u,v;
        cin >> u >> v;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    cout << solve(1, 0, -1);
    return 0;
}

Measured memory_bytes: 18888
N = int(input())
list_a = list(map(int, input().split()))

list_a = sorted(list_a, reverse=True)

Alice = 0
Bob = 0

for i, a in enumerate(list_a):
    if i % 2 == 0:
        Alice += a
    else:
        Bob += a

print(Alice - Bob)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <cstring>
 
using namespace std;
 
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repA(i, a, n) for (ll i = a; i <= (n); ++i)
#define repD(i, a, n) for (ll i = a; i >= (n); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.endd()
#define sz(x) (ll)(x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define ll long long
#define mp make_pair
#define pb push_back
#define clr(a)	memset(a,0x00,sizeof(a))
typedef long double ld;
 
typedef pair<int, int> pii;
typedef vector<ll> vi;
#define mod 1000000007
#define MOD 1e9+7
 


void solve()
{   
    ll h,w;
    cin >> h >> w;
    int a[h][w];
    for(ll i = 0; i < h; ++i){
        for(ll j = 0; j < w; ++j){
            char c; cin >> c;
            a[i][j] = (c == '.')?(1):(0);
        }
    }
    int dp[h][w];
    for(int i = h-1; i >= 0; i--){
        for(int j = w-1; j >= 0; j--){
            if(a[i][j] == 0) dp[i][j] = 0;
            else {
                if(i == h-1){
                    if(j == w-1){
                        dp[i][j] = 1;
                    } else {
                        dp[i][j] = dp[i][j+1];
                    }
                } else {
                    if(j == w-1){
                        dp[i][j] = dp[i+1][j];
                    } else {
                        dp[i][j] = (dp[i+1][j]%mod + dp[i][j+1]%mod)%mod;
                    }
                }
            }
        }
    }
    // rep(i,h){
    //     rep(j,w)cout << dp[i][j] << " ";
    //     cout << "\n"; 
    // }
    cout << dp[0][0];

}
 
 
int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    // long long t;
    // cin >> t;
    // while(t--)
    solve();
}
 
 
// g++ pro.cpp
// ./a.out

Measured memory_bytes: 8064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n; cin >> n;
    vint a(n); vin(a);
    int sum = abs(a[0]);
    repi(i, 1, n) {
        sum += abs(a[i] - a[i - 1]);
    }
    sum += abs(a.back());
    print(sum - abs(a[0]) - abs(a[1] - a[0]) + abs(a[1]));
    repi(i, 1, n) {
        print(sum - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]));
    }
    //print(sum - abs(a[n - 1] - a[n - 2]) - abs(a.back()) + abs(a[n - 2]));

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,m,i=0,j,h,a;
    string s;
    cin >> s;
    h=s.size();
    if(s[h-1]=='s')
    {
        cout << s+"es" << endl;
    }
    else
    {
        cout << s+'s' << endl;
    }
    
    return 0;

}


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

int main() {
	int k,a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	(void)scanf("%d", &k);
	printf("%d", a[k-1]);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq; 

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
	int K=int.Parse(Console.ReadLine());
    string[] S=Console.ReadLine().Split(' ');
    int A=int.Parse(S[0]);
    int B=int.Parse(S[1]);
      bool flg=false;
      for(int i=A;i<=B;i++){
        if(i%K==0){
          flg=true;
          break;
        }
      
      }
      if(flg){
        Console.WriteLine("OK");
      }else{
        Console.WriteLine("NG");
      }
    }
    
  }

}

Measured memory_bytes: 27476
#include <iostream>
#include <vector>

typedef long long int lli;

using namespace std;
int main(void) {
	// Here your code !

	lli n, a;
	cin >> n >> a;
	int x[50] = { 0 };
	for (int i = 0; i < n; i++)cin >> x[i+1];

	long long dp[51][51][2501] = {};

	//i nankotukau
	//j ikuraka
	//k nankotukattaka

	dp[0][0][0] = 1;

	for (int j = 1;j <= n;j++) {
		for (int k = 0;k <= n;k++) {
			for (int s = 0;s <= 2500;s++) {
				if (j >= 1 && s<x[j]) dp[j][k][s] = dp[j - 1][k][s];
				else if (j >= 1 && k >= 1 && s >= x[j]) dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j]];
				else dp[j][k][s] = 0;
			}
		}
	}


	lli res = 0;

	for (int i = 1; i <= 50; i++) {
		res += dp[n][i][i*a];
	}


	cout << res << endl;



}


Measured memory_bytes: 51200
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int X,A,B,ANS;
	cin >> X >> A >> B;
	ANS=X-A-((X-A)/B)*B;
	cout << ANS << endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<int(n);i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int,int>;
const ll mod = 1e9+7;

int main(){
  int n;
  cin>>n;
  vector<int> as(n);
  rep(i,n) cin>>as[i];

  int num=1;
  rep(i,n) if(num==as[i]) num++;

  if(num==1) cout<<-1<<endl;
  else cout<<n-num+1<<endl;

  return 0;
}

Measured memory_bytes: 4056
<?php
fscanf(STDIN, "%s %s", $S, $T);
fscanf(STDIN, "%d %d", $A, $B);
fscanf(STDIN, "%s", $U);

switch ($U) {
    case $S:
        echo(($A -1)." ".$B).PHP_EOL;
        break;
    case $T:
        echo($A." ".($B - 1)).PHP_EOL;
        break;
}


Measured memory_bytes: 4728
class UnionFind() :
	
	def __init__(self,n) :  #n要素で初期化
		#親要素のノード番号を格納。par[x]==xの時そのノードは根
		self.par = [i for i in range(n+1)];
		self.rank = [0]*(n+1);
	
	def root(self,x) :  #木の根を求める
		if self.par[x] == x :  #根
			return x;
		else :
			self.par[x] = self.root(self.par[x]);  #経路圧縮
			return self.par[x];
	
	def unite(self,x,y) :  #xとyの属する集合を併合
		x = self.root(x);
		y = self.root(y);
		if x == y :
			return;
		
		if self.rank[x] < self.rank[y] :  #ランクに関する処理
			self.par[x] = y;
		else :
			self.par[y] = x;
			if self.rank[x] == self.rank[y] :
				self.rank[x] += 1;
	
	def same_check(self,x,y) :  #xとyが同じ集合に属するか否か
		return self.root(x) == self.root(y);

nm = input().split(" ");
n = int(nm[0]);
m = int(nm[1]);
ab = [[0]*2 for i in range(m)];
for i in range(m) :
	s = input().split(" ");
	ab[i][0] = int(s[0]);
	ab[i][1] = int(s[1]);

basefin = UnionFind(n);
check_base = [0]*(n+1);
for i in range(m) :
	basefin.unite(ab[i][0],ab[i][1]);
for i in range(1,n+1) :
	check_base[basefin.root(i)] = 1;
base = sum(check_base);

ans = 0;
for i in range(m) :
	unifin = UnionFind(n);
	check = [0]*(n+1);
	for j in range(m) :
		if j != i :
			unifin.unite(ab[j][0],ab[j][1]);
	for k in range(1,n+1) :
		check[unifin.root(k)] = 1;
	if sum(check) - base == 1 :
		ans += 1;
	
print(ans);


Measured memory_bytes: 3192
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

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

Measured memory_bytes: 1408
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int x[110000];
int y[110000];
int UF[410];
int dame[410];
bool p[410][410];

int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		scanf("%d%d",x+i,y+i);
		x[i]--;y[i]--;
	}
	for(int i=0;i<a;i++){
		for(int j=b-1;j>=0;j--){
			if(p[i][x[j]]==true||x[j]==i){
				if(p[i][y[j]])p[i][i]=true;
				else p[i][y[j]]=true;
			}else if(p[i][y[j]]==true||y[j]==i){
				if(p[i][x[j]])p[i][i]=true;
				else p[i][x[j]]=true;
			}
		}
	}
	int ret=0;
	for(int i=0;i<a;i++)for(int j=i+1;j<a;j++){
		if(p[i][i]||p[i][j]||p[j][i]||p[j][j])continue;
		bool ok=true;
		for(int k=0;k<a;k++){
			if(p[i][k]&&p[j][k])ok=false;
		}
		if(ok)ret++;
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int h, w;
char c[105][105];

int main(void) {

	cin >> h >> w;
	REP(i, h) { REP1(j, w) { cin >> c[i][j]; } }
	REP(i, h) {
		for (int cnt = 0; cnt < 2; cnt++) {
			REP1(j, w) {
				cout << c[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import math


N, D = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

count = 0
for i in range(N):
    for j in range(i+1, N):
        dist = 0
        for d in range(D):
            dist += (X[i][d] - X[j][d]) ** 2
        if float.is_integer(math.sqrt(dist)) == True:
            count += 1
            
print(count)

Measured memory_bytes: 9132
#include<cstdio>

int main() {
    int i, temp;
    int nah = 100000;
    scanf("%d", &i);
    for (; i > 0; i-- ) {
        nah+= nah*5/100;
        temp = nah % 1000;
        if ( temp != 0 ) {
             nah = nah - temp + 1000;
        }
    }
    printf("%d\n", nah);
    return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<string>
#include<cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int exp_mod(long long a, long long b, int m) {
	long long res = 1;
	while (b > 0) {
		if (b&1)
			res = (res * a)%m;
		a = (a * a)%m;
		b >>= 1;
	}
	return (int)res;
}

int fact_mod(int n, int m) {
	long long res = 1;
	for (int i=n; i>0; --i)
		res = (res * i)%m;
	return (int)res;
}

ll comb(int n, int r) {
	long long res = 1;
	for (int i=0; i<r; ++i)
		res = (res * (n - i) )%MOD;
	return ( res * exp_mod(fact_mod(r, MOD), MOD-2, MOD) ) % MOD;
}


int main(){
    int X = 0; cin >> X;
    int Y = 0; cin >> Y;
    if((X+Y)%3 != 0){
        cout << 0;
        return 0;
    }
    else{
        if(Y < X/2 || Y > 2*X){
            cout << 0;
            return 0;
        }
        else{
            long long n = (2*X - Y)/3;
            long long m = (2*Y - X)/3;
            long long ans = comb(n+m, n);
            cout << ans;
        }
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c,d = input().split()
    a = int(a)
    b = int(b)
    c = int(c)
    d = int(d)

    if a*b < c*d:
        print(c*d)
    else:
        print(a*b)

if __name__ == "__main__":
        main()


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ll mod = (ll)1 << 32;
ll tra(char x) {
	if (x >= 'a'&&x <= 'f') {
		return x - 'a' + 10;
	}
	else return x - '0';
}
char invtra(int y) {
	if (y < 10)return '0'+y;
	else return 'a' + y - 10;
}
ll trans(string x) {
	int len = x.length(); ll res = 0; ll now = 1;
	rep(i, len) {
		res += now * tra(x[len - 1 - i]); now *= (ll)16;
	}
	return res;
}
string inv(ll z) {
	if (z == 0)return"0";
	string res="";
	while (z > (ll)0) {
		res += invtra(z % (ll)16); z /=(ll)16;
	}
	reverse(res.begin(), res.end());
	return res;
}
int main() {
	int s; cin >> s;
	rep(i, s) {
		ll sum;
		string x; ll a[9];
		rep(j, 9) {
			cin >> x; a[j] = trans(x);
		}
		ll out = 0;
		rep(k, 32) {
			sum = (ll)0;
			rep(j, 8)sum += a[j];
			if (sum%mod == a[8])break;
			if ((sum^a[8])&((ll)1<<k)) {
				out += ((ll)1<<k);
				rep(j, 9) {
					a[j] ^= ((ll)1 << k);
				}
			}
		}
		cout << inv(out) << endl;
	}
	return 0;
}


Measured memory_bytes: 3136
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let nk: Vec<u32> = read_vec();
    let mut n = nk[0];
    let mut d = 0;

    loop {
        n = n / nk[1];
        d += 1;
        if n == 0 {
            break;
        }
    }

    println!("{}", d);
}

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

using namespace std;
int arr[3][21];
int main()
{
    int n;
    int s=0;
    scanf("%d",&n);
    for (int i=0;i<3;i++) {
        for (int j=1;j<=n;j++) {
            if (i==2&&j==n) continue;
            scanf("%d",&arr[i][j]);
        }
    }
    for (int i=1;i<=n;i++) {
        s+=arr[1][arr[0][i]];
        if (i>=2&&arr[0][i-1]+1==arr[0][i]) s+=arr[2][arr[0][i-1]];
        //printf("%d\n",s);
    }
    printf("%d",s);
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

res = 'YES'
counter_d = Counter(D)
counter_t = Counter(T)

set_t = list(set(T))
for i in set_t:
    if counter_d[i] < counter_t[i]:
        res = 'NO'
        break

print(res)

Measured memory_bytes: 65248
#include<bits/stdc++.h>
using namespace std;
#define test int t;cin>>t;while(t--)
void fastcode()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    /* freopen(" ","r",stdin);
    freopen(" ","w",stdout);*/
    //cout<<fixed<<setprecision(7);
    //π = 3.141592653;
    //reverse(x.begin(),x.end());
    //sort(v1.begin(), v1.end());
    //to sort array sort(arr,arr+n);
    //divide string:substr(s.size()/2,s.size());
    //itoa to convert any system
    fastcode();
    int a,b;
    cin>>a>>b;
    cout<<a*b;
    return 0;
}


Measured memory_bytes: 3620
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define PI acos(-1)
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie (0);
    double t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
    m=2*PI*n;
    cout<<setprecision(20)<<fixed<<m<<endl;
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    string s; cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(s[1]==s[2]&&s[2]==s[3]){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    
}


Measured memory_bytes: 3640
using System;
using System.Linq;
class Program {
	static void Main() {
		int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = b[0], m = b[1];
		int[] a = new int[n];
		for(int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine());
		for(int i = 1; i <= m; i++) {
			for(int j = 0; j < n - 1; j++) {
				if(a[j] % i > a[j + 1] % i) {
					int t = a[j];
					a[j] = a[j + 1];
					a[j + 1] = t;
				}
			}
		}
		for(int i = 0; i < n; i++) {
			Console.WriteLine(a[i]);
		}
	}
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll powermod(ll a,ll b,ll m){
	if(b==0){
		return 1LL;
	}
	if(b%2){
		return (a*powermod(a,b-1LL,m))%m;
	}
	return powermod((a*a)%m,b/2LL,m);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N=in();
	auto A=vecin(N);
	if(A[0]!=0){
		out(0);
		return 0;
	}

	int P[3]={1,0,0};
	ll C=3;
	for(int i=1;i<N;i++){
		ll M=0;
		REP(j,3){
			if(P[j]==A[i]){
				M++;
			}
		}
		if(M==0){
			out(0);
			return 0;
		}
		
		REP(j,3){
			if(P[j]==A[i]){
				P[j]++;
				break;
			}
		}

		C *= M;
		C %= atcoder_mod;
	}

	out(C);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a < b ? 0 : 10);
}


Measured memory_bytes: 256
def z_algorithm(s):
    n = len(s)
    z = [0 for i in range(n)]
    z[0] = n
    i, j = 1, 0
    while i < n:
        while i+j < n and s[j] == s[i+j]:
            j += 1
        z[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while k < j and k + z[k] < j:
            z[i+k] = z[k]
            k += 1
        i += k
        j -= k
    return z

n = int(input())
s = input()

ans = 0
for i in range(n):
    z = z_algorithm(s[i:])
    for j in range(len(z)):
        if z[j] <= j:
            ans = max(ans, z[j])
print(ans)

Measured memory_bytes: 54620
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] h = new int[N];
		for (int i=0;i<N;i++) {
			h[i] = sc.nextInt();
		}

		int[] dp = new int[N];
		Arrays.fill(dp,2111111111);
		dp[0]=0;
		for (int i=0;i<N;i++) {
			for (int j=Math.max(0,i-K);j<i;j++) {
				dp[i]=Math.min(dp[i],dp[j]+Math.abs(h[i]-h[j]));
			}
		}
		System.out.println(dp[N-1]);
	}
}

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

using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int nax = max({a, b, c});
    cout << (a + b + c - nax == nax ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    set<int> s;
    rep(i,1,3){
        int a; cin>>a;
        s.insert(a);
    }
    cout<<sz(s);
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,H,W,A,B;
  cin >> N >> H >> W;
  int ans = 0;
  for (int i = 0; i < N; i++){
    cin >> A >> B;
    if (A >= H && B >= W) ans++;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int targetAmount, yen1;
  cin >> targetAmount >> yen1;
 
  // 500で割ったあまりを算出する
  int surplus = targetAmount % 500;
  
  // 割ったあまりより1円玉が多ければ支払える
  if (yen1 >= surplus) { cout << "Yes" << endl; }
  else { cout << "No" << endl; }
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll k, q;
  cin >> k >> q;
  vector<ll> d(k);
  REP(i, k) cin >> d[i];

  REP(qi, q) {
    ll n, x, m;
    cin >> n >> x >> m;
    ll last = x, eq = 0;
    REP(i, k) {
      ll cnt = (n - 1) / k;
      if ((n - 1) % k > i) ++cnt;
      last += cnt * (d[i] % m);
      if ((d[i] % m) == 0) eq += cnt;
    }
    ll ans = n - 1 - (last / m - x / m) - eq;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define int long long
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n,q;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
ll num[200005];
vector<ll> edge[200005];
void dfs(int v,int p)
{
    for(auto i:edge[v])
    {
        if(i==p) continue;
        num[i]+=num[v];
        dfs(i,v);
    }
}
signed main()
{

    //ios_base::sync_with_stdio(0),cin.tie(0);
    while(cin>>n>>q)
    {
        rep(i,n-1)
        {
            ll x,y;
            cin>>x>>y;
            edge[x].pb(y);
            edge[y].pb(x);
        }
        rep(i,q)
        {
            ll p,x;
            cin>>p>>x;
            num[p]+=x;
        }
        dfs(1,0);
        rep1(i,n) cout<<num[i]<<" ";
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 24320