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

public class Main{
	public static void main(String args[]) {
	
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		int q=sc.nextInt();
		int k[]=new int[q];

		
		for(int i=0;i<q;++i) {
			k[i]=sc.nextInt();
			int countd=0, countm=0;
			long ans=0,next=0;
			for (int m=0;m<n;++m) {
				
				if(m-k[i]>=0) {
				if(s.charAt(m-k[i])=='D') {--countd; next=next-countm;}
				else if(s.charAt(m-k[i])=='M')--countm; 
				}
				
				if(s.charAt(m)=='D')++countd;
				else if(s.charAt(m)=='M') {++countm; next=next+countd;} 
				else if(s.charAt(m)=='C')ans=ans+next;
			}
			System.out.println(ans);
		}
		
	}
}


Measured memory_bytes: 34776
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int n;V<int> v[100005]; 
bool f[100005];
void dfs(int p){
	if(f[p])RE;
	f[p]=1;
	for(int i=0;i<v[p].size();i++)dfs(v[p][i]);
}
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	int m,x,y,z;
	cin>>n>>m;
	FOR(i,1,m){
		cin>>x>>y>>z;
		v[x].PB(y);
		v[y].PB(x);
	} 
	int ans=0;
	FOR(i,1,n){
		if(!f[i]){
			dfs(i);ans++;
		}
	}
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 8960
N,M = map(int,input().rstrip().split(" "))
if abs(N - M) > 1:
    print(0)
else:
    ans = 1
    for i in range(1,N + 1):
        ans *= i
        ans %= 10 ** 9 + 7
    for i in range(1,M + 1):
        ans *= i
        ans %= 10 ** 9 + 7
    if N == M:
        ans *= 2
        ans %= 10 ** 9 + 7
    print(ans)

Measured memory_bytes: 9156
#include<iostream>
#include<cmath>

using namespace std;
int N,K;

void solve(){
    cin >> N >> K;
    for(int i=0;i<30;i++){
        if(pow(K,i)<= N && pow(K,i+1)>N){
            cout << i+1;
            break;
        }
    }
}

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

Measured memory_bytes: 256
#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()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

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

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

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
int N, M;
vector<int> H;
vvec<int> G;
vector<bool> used;

vector<int> dfs(int cur, int pre, vector<int> &v) {
    if (used[cur])return v;
    used[cur] = true;
    v.push_back(cur);
    for (auto nv: G[cur]) {
        if (nv == pre)continue;
        dfs(nv, cur, v);
    }
    return v;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    cin >> N >> M;
    H.resize(N);
    rep(i, N)cin >> H[i];
    G.resize(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    used.assign(N, false);
    int ans = 0;
    /*
    rep(i, N) {
        if (used[i])continue;
        vector<int> x;
        dfs(i, -1, x);
        print(x);
        int mx = 0;
        for (auto idx: x) {
            chmax(mx, H[idx]);
        }
        int cnt = 0;
        for (auto idx: x) {
            if (mx == H[idx])cnt++;
        }
        if(cnt == 1)ans++;
    }
     */
    rep(i,N){
        if(used[i])continue;
        bool ok = true;
        for(auto nv: G[i]){
            if(H[i] < H[nv]){
                ok = false;
            }
            else if(H[i] == H[nv]){
                ok = false;
                used[nv] = true;
            }
            else{
                used[nv] = true;
            }
        }
        if(ok)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8720
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;// 1000000007;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL X;
	cin >> X;
	LL ans = (X / 500) * 1000;
	X -= (X / 500) * 500;
	ans += (X / 5) * 5;
	cout << ans << "\n";
	return 0;
}

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

int main() {
    int h, w, n, sr, sc;
    cin >> h >> w >> n >> sr >> sc;
    string s, t;
    cin >> s >> t;
    int left = 1, right = w, top = 1, bottom = h;
    for (int i = n - 1; i >= 0; i--) {
        if (right < left || bottom < top) {
            cout << "NO" << endl;
            return 0;
        }
        
        if (t.at(i) == 'L' && right < w) right++;
        else if (t.at(i) == 'R' && 1 < left) left--;
        else if (t.at(i) == 'U' && bottom < h) bottom++;
        else if (t.at(i) == 'D' && 1 < top) top--;

        if (s.at(i) == 'L') left++;
        else if (s.at(i) == 'R') right--;
        else if (s.at(i) == 'U') top++;
        else if (s.at(i) == 'D') bottom--;
    }

    if (left <= sc && sc <= right && top <= sr && sr <= bottom) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,a,n) for(ll i=a;i<n;i++)
#define w(_t) ll _t;cin>>_t;while(_t--)
ll md=1000000007;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    n=1-n;
    cout<<n;
    return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    string s;
    cin >>s;
    int S=s.size();

    int c=-1,f=-1;
    rep(i,S)
    {
        if(s[i]=='C')
        {
            c=i;
            break;
        }
    }
    for(int i=S-1; i>=0; --i)
    {
        if(s[i]=='F')
        {
            f=i;
            break;
        }
    }

    string ans="No";
    if(c!=-1 && f!=-1 && c<f) ans="Yes";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

h,w = map(int,input().split())

a = np.empty(0,dtype=np.unicode)
for i in range(h):
    a = np.append(a,[x for x in input()])

a = np.reshape(a,(h,w))
a = a[:,np.any(a == '#',axis=0)]
a = a[np.any(a == '#',axis=1)]

a = a.tolist()
for i in a:
    print("".join(i))


Measured memory_bytes: 12496
// https://atcoder.jp/contests/abc060/tasks/abc060_b

#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int a, b, c, d = 0;
  set<int> mod;
  string r;

  cin >> a >> b >> c;

  while (true)
  {
    d += a;
    d = d % b;
    if (d == c)
    {
      r = "YES";
      break;
    }
    else
    {
      int ls = mod.size();
      mod.insert(d);
      if (ls == mod.size())
      {
        r = "NO";
        break;
      }
    }
  }

  cout << r << '\n';

  return 0;
}


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

int main(){
    int n,ans=0;
    long long d;cin >> n >> d;
    d = d*d;
    for(int i=0; i<n; i++){
        long long x,y;cin >> x >> y;
        if(d>=x*x+y*y) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

int a[maxn];
ll b[2 * maxn], c[2 * maxn];

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int n, m;
    scanf("%d%d", &n, &m);
    ll sum = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i < n; i++) {
        if (a[i] == a[i + 1]) continue;
        if (a[i] < a[i + 1]) {
            sum += a[i + 1] - a[i];
            int l = a[i] + 1, r = a[i + 1];
            b[l] += a[i] + 1;
            b[r + 1] -= a[i] + 1;
            c[l] += 1;
            c[r + 1] -= 1;
        } else {
            sum += m - a[i];
            sum += a[i + 1];
            int l1 = a[i] + 1, r1 = m;
            int l2 = 1, r2 = a[i + 1];
            if (l1 <= r1) {
                b[l1] += a[i] + 1, b[r1 + 1] -= a[i] + 1;
                c[l1] += 1, c[r1 + 1] -= 1;
            }
            if (l2 <= r2) {
                b[l2] += a[i] + 1 - m, b[r2 + 1] -= a[i] + 1 - m;
                c[l2] += 1, c[r2 + 1] -= 1;
            }
        }
    }
    for (int i = 1; i <= m; i++) {
        b[i] += b[i - 1];
        c[i] += c[i - 1];
    }
    ll ans = LL_INF;
    for (int i = 1; i <= m; i++) {
        ll delta = (1LL * i * c[i] - b[i]);
        ans = min(ans, sum - delta);
    }
    printf("%lld\n", ans);

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

template<class T,uint mod>
struct RollingHash_{
	vector< uint > hashed, power;

	inline uint mul(uint a, uint b){
		return a*(unsigned long long)b%mod;
	}
	RollingHash_(){}
	RollingHash_(T s, uint base = 10007) {
		int sz = (int) s.size();
		hashed.assign(sz + 1, 0);
		power.assign(sz + 1, 0);
		power[0] = 1;
		for(int i = 0; i < sz; i++) {
			power[i + 1] = mul(power[i], base);
			hashed[i + 1] = mul(hashed[i], base) + s[i];
			if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
		}
	}

	uint get(int l, int r){
		uint ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
		if(ret >= mod) ret -= mod;
		return ret;
	}
};

typedef pair<uint,uint>Hash;

template<class T>
struct RollingHash{
	RollingHash_<T,998244353>RH1;
	RollingHash_<T,1000000007>RH2;

	RollingHash(){}
	RollingHash(T s){
		RH1=RollingHash_<T,998244353>(s);
		RH2=RollingHash_<T,1000000007>(s);
	}

	Hash get(int l,int r){
		return make_pair(RH1.get(l,r),RH2.get(l,r));
	}
};

int a[300000];
int b[300000];

int main(){
	int n;cin>>n;
	rep(i,n)scanf("%d",&a[i]);
	rep(i,n)scanf("%d",&b[i]);
	vector<ll>c(2*n),d(2*n);
	rep(i,n)c[i]=(a[i]^a[(i+1)%n]),c[n+i]=c[i];
	rep(i,n)d[i]=(b[i]^b[(i+1)%n]),d[n+i]=d[i];
	RollingHash<vector<ll>>rh1(c),rh2(d);
	rep(i,n){
		if(rh1.get(i,i+n)==rh2.get(0,n)){
			printf("%d %d\n",i,a[i]^b[0]);
		}
	}
}

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

using namespace std;

const int DIM = 507;

#define int long long

int v[DIM][DIM];
bool vis[DIM][DIM];

int black;
int white;

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};

int n, m;

bool isIn(int x, int y)
{
	return (x <= n && x >= 1 && y <= m && y >= 1);
}

void dfs(int x, int y)
{
	if(v[x][y] == 1)
		black++;
	else
		white++;
	
	vis[x][y] = 1;
	
	for(int i = 0; i < 4; i++)
	{
		int new_x = x + dx[i];
		int new_y = y + dy[i];
		
		if(isIn(new_x, new_y) && v[new_x][new_y] == (v[x][y] ^ 1) && vis[new_x][new_y] == 0)
			dfs(new_x, new_y);
	}
}

main()
{
	cin >> n >> m;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
		{
			char c;
			cin >> c;
			
			if(c == '#')
				v[i][j] = 1;
			else
				v[i][j] = 0;
		}
	
	int pr = 0;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(vis[i][j] == 0)
			{
				black = 0;
				white = 0;
				
				dfs(i, j);
				
				pr += black * white;
			}
	
	cout << pr;
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  long long n, k; cin >> n >> k;
  n %= k;
  cout << min(n, abs(n-k)) << endl;
  return 0;
}

// EOF


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#define ll long long
using namespace std;
const int N=100005;
struct node{
	ll a,b,c;
	bool operator<(const node &A)const{
	return (a-b)<A.a-A.b;}
}p[N];ll lf[N];priority_queue
<ll,vector<ll>,greater<ll> >q;
int n,m,x,y,z;ll bs=0,ans=0,sum=0;
int main(){
	scanf("%d%d%d",&x,&y,&z);n=x+y+z;
	for(int i=1;i<=n;i++)
	scanf("%lld%lld%lld",&p[i].a,&p[i].b
	,&p[i].c),bs+=p[i].c;sort(p+1,p+1+n);
	for(int i=1;i<=y;i++)
	sum+=p[i].b-p[i].c,
	q.push(p[i].b-p[i].c);
	for(int i=y+1;i<=n-x+1;i++){
		lf[i]=sum;sum+=p[i].b-p[i].c;
		q.push(p[i].b-p[i].c);
		sum-=q.top();q.pop();
	} while(q.size()) q.pop();sum=0;int t=0;
	for(int i=n;i>=n-x+1;i--)
	sum+=p[i].a-p[i].c,
	q.push(p[i].a-p[i].c),t=i;
	for(int i=t-1;i>=y;i--){
		ans=max(ans,bs+lf[i+1]+sum);
		sum+=p[i].a-p[i].c;
		q.push(p[i].a-p[i].c);
		sum-=q.top();q.pop();
	} printf("%lld\n",ans);return 0;
}

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

public class ABC164B {
	private static void Main(string[] args) {
		var input = ReadDoublesAsArray();
		var a = input[0];
		var b = input[1];
		var c = input[2];
		var d = input[3];

		var answer = (Math.Ceiling(c / b) <= Math.Ceiling(a / d)) ? "Yes" : "No";
		Console.WriteLine(answer);
	}

	private static double[] ReadDoublesAsArray() => Console.ReadLine().Trim().Split().Select(x => double.Parse(x)).ToArray();
}

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

public static partial class Program
{
    public static void Main()
    {
        var s = CRL();
        var len = 15 - s.Length;
        var cnt = s.Count(x => x == 'o');
        CWL(len + cnt >= 8 ? "YES" : "NO");
    }
}

public static partial class Program
{
    //テンプレここから
    public static int Sigma(int n, int next = 1, int val = 0) => next > n ? val : Sigma(n, next + 1, val + next);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static readonly int[] Dx = new[] {0, -1, 0, 1};
    public static readonly int[] Dy = new[] {-1, 0, 1, 0};
    public const int Mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToLong();
    public static int ToInt(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    public static string JoinToStr(this IEnumerable<int> array, string sep = "")
        => array.Select(x => x.ToString()).Join(sep);

    //テンプレここまで
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };



int H,W;
vs S;


int main()
{
  int left[2010][2010],right[2010][2010],up[2010][2010],down[2010][2010];
  cin >> H >> W;
  S.resize(H);
  rep(i,H) cin >> S[i];
  

  //left
  rep(i,H){
      int cur = 0;
      rep(j,W){
          //...#..#..みたいな感じだと例えばi=0なら自分含めて3マス進んで壁に当たるからS[0]=3が入る,壁は0が入る
          if(S[i][j] == '#') cur=0;
          else cur++;
          left[i][j] = cur;
      }
  }

  //right
  rep(i,H){
      int cur=0;
      for (int j = W-1; j >=0; j--)
      {
          if(S[i][j] == '#') cur=0;
          else cur++;
          right[i][j] = cur;
      }
  }

  //down
  rep(j,W){
      int cur=0;
      rep(i,H){
          if(S[i][j] == '#') cur=0;
          else cur++;
          down[i][j] = cur;
      } 
  }
   //up
   rep(j,W){
      int cur=0;
     for(int i=H-1;i>=0;i--){
          if(S[i][j] == '#') cur=0;
          else cur++;
          up[i][j] = cur;
      } 
  }
  
  int ans=0;
  
  rep(i,H){
      rep(j,W){
          if(S[i][j] == '#') continue;
          ans = max(ans,left[i][j]+right[i][j]+up[i][j]+down[i][j]-3);//-3は注目しているマスが4個重複するので-3
      }
  }

  fin(ans);
  
}



Measured memory_bytes: 67456
from math import factorial
def mul(a, b):
    mod = 1000000007
    return ((a % mod) * (b % mod)) % mod
N,M = map(int,input().split())
if abs(N-M) >= 2:
    print(0)
elif N == M:
    k = factorial(N) % (10**9+7)
    ans = mul(k,k)
    print(mul(2,ans))
else:
    k = factorial(M) % (10**9+7)
    l = factorial(N) % (10**9+7)
    ans = mul(k,l)
    print(ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a = 0;
  string s;
  in(s);
  rep(i, 4){
    if(s[i] == '+')
      a++;
    else
      a--;
  }
  out(a);
  memi;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int N;
  string S;
  cin >> N >> S;
  bool ans = true;
  if(N%2 == 1) {
    ans = false;
  }
  else {
    N /= 2;
  }
  string T;
  REP(i,N){
    T += S.at(i);
  }
  T += T;
  if(T != S){
    ans = false;
  }
  if(ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    string s;
    cin >> s;
    int a = s.size();
    vector<char> v(3);
    if (a == 2)
    {
        cout << s;
    }
    else
    {
        v[0] = s[2];
        v[1] = s[1];
        v[2] = s[0];
        rep(i, 3)
        {
            cout << v[i];
        }
    }
    cout << endl;
}

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

typedef long long ll;

using namespace std;

int main() {

    int N;
    cin >> N;

    vector<double> v(N);

    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }

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

    double ans = (v[0] + v[1]) / pow(2.0, N - 1);

    for (int i = 2; i < N; i++) {
        ans += v[i] / pow(2.0, N - i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int M, D;
    cin >> M;
    cin >> D;
    
    int count = 0;
    for (int i = 1; i <= M; i++) {
        for (int j = 22; j <= D; j++) {
            int d1 = j % 10;
            if (d1 < 2) {continue;}
            int d10 = j / 10;
            if ((d1 * d10) == i) {
                count++;
            }
        }
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;



int32_t main(){
    vaibhavv06;
	int k,x; cin>>k>>x;
	cout<<(500*k >=x ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a, b, c;
	cin >> a >> b;
	c = a + b;
	int aa = stoi(c);
	for (int i = 0; i <= 1000; i++)
	{
		if ((i*i) == aa)
		{
			cout << "Yes" << "\n";
			break;
		}
		if (i == 1000)
		{
			cout << "No" << endl;
		}
	}
}


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  static const ll MAX = 100010LL;
  ll N, M, indeg[MAX], dp[MAX];
  bool visited[MAX];
  vector<ll> G[MAX], RG[MAX], topo;

  void init() {
    scanf("%lld %lld", &N, &M);
    ll x, y;
    rep(i, M) {
      scanf("%lld %lld", &x, &y);
      x--; y--;
      indeg[y]++;
      G[x].push_back(y);
      RG[y].push_back(x);
    }
  }

  void bfs(ll u) {
    queue<ll> que;
    que.push(u);
    while(!que.empty()) {
      ll s = que.front(); que.pop();
      if(visited[s]) continue;
      visited[s] = true;
      topo.push_back(s);
      for(const ll& t : G[s]) {
        indeg[t]--;
        if(indeg[t] <= 0 && !visited[t]) {
          que.push(t);
        }
      }
    }
  }

  void solve() {
    rep(i, N) if(indeg[i] <= 0 && !visited[i]) bfs(i);
    ll ans = 0;
    for(const ll& t : topo) {
      for(const ll& s : RG[t]) {
        dp[t] = max(dp[t], dp[s]+1);
        ans = max(ans, dp[t]);
      }
    }
    cout << ans << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 13948
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
int t,n,a[55][55],pa[55],size[55];
queue<int>q;
struct Graph
{
	struct Edge
	{
		int to;
		int nxt;
	}e[105];
	int edgenum,head[55],pa[55],d[55];
	void add(int u,int v)
	{
		e[++edgenum].to=v;
		e[edgenum].nxt=head[u];
		head[u]=edgenum;
		d[v]++;
	}
	void dfs(int node)
	{
		for(int hd=head[node];hd;hd=e[hd].nxt)
		{
			int to=e[hd].to;
			if(to==pa[node])continue;
			pa[to]=node;
			dfs(to);
		}
	}
	bool topsort()
	{
		for(int i=1;i<=n;i++)
		  if(d[i]==0)q.push(i);
		while(!q.empty())
		{
			int node=q.front();
			q.pop();
			for(int hd=head[node];hd;hd=e[hd].nxt)
			{
				int to=e[hd].to;
				d[to]--;
				if(d[to]==0)q.push(to);
			}
		}
		for(int i=1;i<=n;i++)
		  if(d[i])return 0;
		return 1;
	}
}T1,T2,G;
int T;
int find(int x)
{
	return x==pa[x]?x:pa[x]=find(pa[x]);
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		for(int i=1;i<=n;i++)pa[i]=i,size[i]=1;
		memset(a,0,sizeof(a));
		T1.edgenum=0;
		memset(T1.head,0,sizeof(T1.head));
		memset(T1.d,0,sizeof(T1.d));
		T2.edgenum=0;
		memset(T2.head,0,sizeof(T2.head));
		memset(T2.d,0,sizeof(T2.d));
		for(int i=1;i<n;i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			T1.add(u,v);
			T1.add(v,u);
			a[u][v]=a[v][u]=1;
		}
		for(int i=1;i<n;i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
			T2.add(u,v);
			T2.add(v,u);
			if(a[u][v])size[find(v)]+=size[find(u)],pa[find(u)]=find(v);
		}
		int ans=-1;
		for(int i=1;i<=n;i++)
		{
			if(find(i)!=i)continue;
			T1.pa[i]=T2.pa[i]=0;
			T1.dfs(i);
			T2.dfs(i);
			G.edgenum=0;
			memset(G.head,0,sizeof(G.head));
			memset(G.d,0,sizeof(G.d));
			for(int j=1;j<=n;j++)
			{
				if(find(j)!=i&&T1.pa[j]&&find(T1.pa[j])!=i) G.add(j,T1.pa[j]);
				if(find(j)!=i&&T2.pa[j]&&find(T2.pa[j])!=i) G.add(T2.pa[j],j);
			}
			if(G.topsort())ans=max(ans,size[i]);
		}
		if(ans==-1)
		{
			for(int i=1;i<=n;i++)
			{
				if(T1.d[i]!=1)continue;
				T2.pa[i]=0;
				T2.dfs(i);
				for(int j=1;j<=n;j++)
				{
					if(i==j)continue;
					T1.pa[j]=0;
					T1.dfs(j);
					G.edgenum=0;
					memset(G.head,0,sizeof(G.head));
					memset(G.d,0,sizeof(G.d));
					for(int k=1;k<=n;k++)
					{
						if(k!=i&&T1.pa[k]!=i)G.add(k,T1.pa[k]);
						if(k!=i&&T2.pa[k]!=i)G.add(T2.pa[k],k);
					}
					if(G.topsort())ans=0;
				}
			}
		}
		if(ans!=-1)printf("%d\n",n-ans);
		else printf("-1\n");
	}
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    int n,x;
    cin >> n >> x;

    int sum=0;
    int l=0;
    int res=1;
    REP(i,n){
        cin >> l;
        sum+=l;
        if(sum<=x)res++;
    }
    cout << res << endl;

}


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

S = input()
odd = True
even = True

for i in range(len(S)):
    if (i+1)%2==0:
        if S[i] == "R":
            even = False
    else:
        if S[i] == "L":
            odd = False
    if (odd and even) == False:
        print("No")
        exit()

print("Yes")


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

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin >> l.at(i);
    }
    sort(l.begin(),l.end());
    int total=0;
    for(int i=0;i<n-1;i++){
        total += l.at(i);
    }
    if(l.at(n-1)<total){
        cout << "Yes";
    }
    else cout << "No";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF 1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second
#define setprecision(d) cout << fixed << setprecision(d);

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

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


signed main(){

	ll n,m = 0,k,ans = 0;
	cin >> n >> k;

	ll a[n];
	
	ll memo = 0;
	rep(i,0,n){
		cin >> a[i];
		rep(j,0,i){
			if(a[j] > a[i]) memo++;
		}
	}
	


	sort(a,a+n);


	rep(i,0,n){
		rep(j,0,n){
			if(a[i] < a[j]) m++;
		}
	}
	

	
	
	//memo2 = m*k*(k-1)/4;

	ll memo2 = k;
	memo2 *= (k-1);
	memo2 /= 2;
	memo2 %= (ll)(1e9+7);

	memo2 *= m;
	memo2 %= (ll)(1e9+7);
	


	ans += memo2;
	ans %= (ll)(1e9+7);
	ans += memo*k;
	ans %= (ll)(1e9+7);
	

	cout << ans << endl;

	


    return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
count0 = 0
ans = 1
for i in range(1, n+1):
	count = 0
	j = i
	while j % 2 == 0:
		j = j / 2
		count += 1
		if count > count0:
			ans = i
			count0 = count
print ans

Measured memory_bytes: 2568
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	long long x, y;
	cin >> x >> y;
	long long cnt = 0;
	while (x <= y) {
		cnt++;
		x *= (long long)2;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1000005,M=998244353;;
int n,m,k,t,u,v,i;
long long ans,fac[N],inv[N];
long long C(int n,int m)
{
	return fac[n]*inv[m]%M*inv[n-m]%M;
}
int main()
{
	scanf("%d %d",&n,&m);
	n+=m;
	ans=max(m,n-m);
	fac[0]=inv[0]=inv[1]=1;
	for(i=2;i<=n;++i)
		inv[i]=inv[M%i]*(M-M/i)%M;
	for(i=1;i<=n;++i)
	{
		fac[i]=fac[i-1]*i%M;
		inv[i]=inv[i-1]*inv[i]%M;
	}
	long long t=fac[m]*fac[n-m]%M*inv[n]%M;
	for(i=1;2*i<=n&&i<=m&&i<=n-m;++i)
		ans=(ans+t*C(2*i,i)%M*inv[2]%M*C(n-2*i,m-i))%M;
	cout<<(ans%M+M)%M;
}


Measured memory_bytes: 19280
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
            for(var i = 0; i < line.Length; i++)
            {
                if(line[i] == 0)
                {
                    WriteLine(i + 1);
                }
            }
        }
    }
}


Measured memory_bytes: 18996
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    String t = in.readLine();
    int count = 0;
    for(int i=0; i<s.length(); i++) {
      if(!s.substring(i,i+1).equals(t.substring(i,i+1)))
        count += 1;
    }
    System.out.println(count);
  }
}

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

long long n,k,i,ans,penuh,sisa;

int main() {
  scanf("%lld%lld\n",&n,&k);
  ans = n*n;
  
  for (i=1 ; i<=n ; i++) {
   	penuh = n / i;
    sisa = n % i;
    
    ans -= penuh * min(i,(k));
    ans -= max(0LL,min(k-1,sisa));
    //printf("%lld\n",ans);
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int h, a;
	int aCount = 0;

	scanf("%d%d", &h, &a);

	/* モンスターの体力が0以下になるまで、攻撃回数を数える */
	while (h > 0)
	{
		h -= a;
		aCount++;
	}

	printf("%d", aCount);

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0;i<N;i++){
    cin >> X.at(i);
  }
  int m=0;
  for(int i=0;i<N;i++){
    m= m+X.at(i);
  }
  int s=0;
  int t=0;
  int u=0;
  if (m%N==0){
    for(int i=0;i<N;i++){
      s =s+(X.at(i)-m/N)*(X.at(i)-m/N);
    }
  }
  else{
      for(int i=0;i<N;i++){
         s =s+(X.at(i)-m/N)*(X.at(i)-m/N);
         u =u+(X.at(i)-(m/N+1))*(X.at(i)-(m/N+1));
      }
  }
   if(m%N==0){
     cout<<s<<endl;
   }
   else{
     
     cout<<min(s,u)<<endl;
   }
      
      
    
  
  
}

Measured memory_bytes: 256
using System;

namespace ABC109A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            if (a * b % 2 == 0)
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#A - Frog 1

n=int(input())
h = list(map(int,input().split()))

h.insert(0,0)
#h[i]が足場iの高さ

#c[i]を足場iにたどり着くまでに支払うコストの総和の最小値とする。

c=[0, 0]
c2 = abs(h[2]-h[1])
c.append(c2)

for i in range(3,n+1):
    #c[3]からc[n]まで順に計算する
    #c[i]
    ck = min(c[i-1]+abs(h[i]-h[i-1]),c[i-2]+abs(h[i]-h[i-2]))
    c.append(ck)
print(c[n])

Measured memory_bytes: 13980
from itertools import groupby as gb
s=input()
k=int(input())
if len(set(s))==1:print((len(s)*k)//2);exit()
elif len(s)==2 and len(set(list(s)))==1:print(k);exit()
ji=[len(list(b))//2 for a,b in gb(s)]
l=k*sum(ji)
if s[0]==s[-1]:
  ji=[len(list(b)) for a,b in gb(s)]
  if ji[0]%2 and ji[-1]%2:l+=k-1
print(l)

Measured memory_bytes: 3064
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
	int groups;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()), groups(0) {};
	UnionFind(unsigned size__) : size_(size__), groups(size_) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		groups--;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
	int get_group()
	{
		return groups;
	}
};

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
class Edge
{
public:
	int from;
	vector<int> to;
	Edge(int pfrom, vector<int> pto) : from(pfrom), to(pto)
	{
	}
	Edge(){}
};

int L[100010];

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

	int N, M;
	
	cin >> N >> M ;
	UnionFind tree(N);

	vector<int> v(M,-1);
	
	rep(i, N)
	{
		int k;
		cin >> k;
		rep(j, k)
		{	
			int lan;
			cin >> lan;
			lan--;
			if (v[lan] == -1)
			{
				v[lan] = i;
			}	
			else
			{
				tree.unite(v[lan], i);
			}
			
		}
	}

	//cout << tree.get_group() << endl;
	if (tree.get_group() == 1)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	
	return 0;
}


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

#define ll long long

int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if (k<=a){
        cout<<(ll)k;
    }
    else if (k<=a+b){
        cout<<(ll)a;
    }
    else{
        cout<<(ll)(a-(k-a-b));
    }
    
}

Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef unsigned long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
 



int main(void)
{
    int n;
    
    cin>>n;
    int ans2 =0;
    int d[17][17];
    bool t[17][17];
    int a[17];
    for(int i=1;i<=n;i++)
    {
        
        cin>>a[i];
        for(int j=0;j<a[i];j++)
        {
            cin>>d[i][j];
            cin>>t[i][j];
        }
    }

    for(int bit =0;bit<(1<<n);bit++)
    {
        vector<bool> person(20);
        int ans =0;
        for(int k=0;k<n;k++)
        {
            if(bit&1<<k) 
            {
                person[k+1]=true;
                ans ++;
            }
            else person[k+1] = false;
        }
        bool check = true;

        for(int k=1;k<=n;k++)
        {
            if(person[k])
            {
                for(int l=0;l<a[k];l++)
                {
                    if(person[d[k][l]]!=t[k][l]) check =false;
                }
            }

        }

    if(check) ans2=max(ans,ans2);

    }

cout<<ans2<<endl;

}

Measured memory_bytes: 384
N, K = gets.chomp.split(" ").map(&:to_i)
conn = Array.new(N){Array.new(N, false)}

if K > N * (N - 1) / 2 - (N - 1)
    puts "-1"
    exit
end

for j in 1..N-1
    conn[0][j] = true
end

d1 = (N * (N - 1) / 2 - (N - 1)) - K
for i in 1..N-2
    break if d1 == 0
    for j in i+1..N-1
        break if d1 == 0
        conn[i][j] = true
        d1 -= 1
    end
end

puts conn.flatten.count(true)
for i in 0..N-2
    for j in i+1..N-1
        if conn[i][j]
            puts "#{i+1} #{j+1}"
        end
    end
end

Measured memory_bytes: 1916
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll a, b;
  cin >> a >> b;

  if (a>=b){
    ll sb = 0;
    REP(i,a){
      sb += b*pow(10,i);
    }
    cout << sb << "\n";
  } else {
    ll sa = 0;
    REP(i,b){
      sa += a*pow(10,i);
    }
    cout << sa << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	
	int i,n=0;
	char m[1200];

	while(1){
		scanf("%c",&m[n]);
		if(m[n]=='\n')break;
		if('A'<=m[n]&&'Z'>=m[n]){
			m[n]+=32;
		}
		else if('a'<=m[n]&&'z'>=m[n]){
			m[n]-=32;
		}
		n=n+1;
	}

	for(i=0;i<n;i++){
		printf("%c",m[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 524
fun main(args: Array<String>){
    val s = readLine()!!
    val front = s.substring(0, (s.length-1)/2)
    val end = s.substring((s.length+3)/2 - 1, s.length)
    val check1 = palindromeCheck(s)
    val check2 = palindromeCheck(front)
    val check3 = palindromeCheck(end)
    if(check1 && check2 && check3){
        println("Yes")
    }else{
        println("No")
    }
}

fun palindromeCheck(s: String): Boolean{
    val length = s.length
    val lastIndex = s.lastIndex
    if(length % 2 != 0) {
        for (i in 0..(length - 1) / 2) {
            if (s[i] != s[lastIndex - i]) {
                return false
            }
        }
    }else{
        for (i in 0..length / 2) {
            if (s[i] != s[lastIndex - i]) {
                return false
            }
        }
    }
    return true
}

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

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

ll n, x;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> x;
	cout << 3LL * (n - __gcd(n, x)) << endl;
}

Measured memory_bytes: 256
fn solve(hs: Vec<usize>) -> usize {
    let mut dp = vec![0; hs.len()];

    for i in 1..hs.len() {
        if hs[i - 1] >= hs[i] {
            dp[i] = dp[i - 1] + 1;
        }
    }

    *dp.iter().max().unwrap()
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![10, 4, 8, 7, 3]), 2);
    assert_eq!(solve(vec![4, 4, 5, 6, 6, 5, 5]), 3);
    assert_eq!(solve(vec![1, 2, 3, 4]), 0);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let _n = parse_line!(usize);
    let hs = parse_vec!(usize);

    println!("{}", solve(hs));
}


Measured memory_bytes: 8444