akhauriyash/Code-Regression huggingface dataset:
sx,sy,tx,ty = map(int, input().split())

tx-=sx
ty-=sy

res=[]

for i in range(ty):
    res.append("U")
for i in range(tx+1):
    res.append("R")
for i in range(ty+1):
    res.append("D")
for i in range(tx+1):
    res.append("L")
res.append("U")

res.append("L")
for i in range(ty+1):
    res.append("U")
for i in range(tx+1):
    res.append("R")
for i in range(ty+1):
    res.append("D")
for i in range(tx):
    res.append("L")

for i in res:
    print(i,end='')

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

int32_t main()
{
    IOS;

    int a,b,k;
    
    cin>>a>>b>>k;
    
    char ch='0';
    
    for(int i=1;i<=k;i++)
    {
         if(ch=='0')
         {
              if(a%2!=0)
               a--;
               
               int add=a/2;
               
               a-=add;
               b+=add;
               ch='1';
         }
         else 
         {
              if(b%2!=0)
               b--;
               int add=b/2;
               b-=add;
               a+=add;
               ch='0';
         }
    }
    
    cout<<a<<" "<<b;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int D,T,S;
      cin >> D >> T >> S;
      
      if((double)D/(double)S < T ||(double)D/(double)S == T ){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
      
    }

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;

typedef pair<int,int> ii;
typedef pair<int,ii> iii;
iii query[100100];
int n,m,x,y,d[100100],mark[100100];
vector<int> graph[100100];
bool vis[100100];
vector<int> v;
int travelled[100100];

int main() {
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d %d",&x,&y);
		graph[x].pb(y);
		graph[y].pb(x);
	}
	int qq;
	scanf("%d",&qq);
	for(int i=0;i<qq;i++){
		scanf("%d %d %d",&query[i].fi, &query[i].sc.fi, &query[i].sc.sc);
	}
	queue<int> q;
	for(int i=qq-1;i>=0;i--){
		x = query[i].fi;
		q.push(x);
		while(v.size()) vis[v[v.size()-1]] = 0, v.pop_back();
		d[x] = 0;
		vis[x] = 1;
		while(!q.empty()){
			x = q.front();
			v.pb(x);
			q.pop();
			if(!mark[x]) mark[x] = query[i].sc.sc;
			if(travelled[x]>=query[i].sc.fi - d[x]) continue;
			travelled[x] = query[i].sc.fi - d[x];
			for(int j=0;j<graph[x].size();j++){
				y = graph[x][j];
				if(!vis[y] && d[x]+1<=query[i].sc.fi){
					vis[y] = 1;
					d[y] = d[x]+1;
					q.push(y);
				}
			}
		}
	}
	for(int i=1;i<=n;i++) cout<<mark[i]<<endl;
	return 0;
}

Measured memory_bytes: 9848
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int max = 0;
        long prev = sc.nextLong();
        int cnt = 0;
        for(int i = 1; i < N; i++){
            long n = sc.nextLong();
            if(prev >= n){
                cnt++;
            }else{
                if(max < cnt){
                    max = cnt;
                }
                cnt = 0;
            }
            prev = n;
        }
        if(max < cnt){
            max = cnt;
        }
        System.out.println(max);
    }
}


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

using ll = long long;

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    ll ans = 0;
    for(int i=0;i<n-k;i++){
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc172_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            int ans = 0;

            for (int i = 0; i< S.Length; i++)
            {
                if(S[i] != T[i])
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
            Console.Read();
        }
    }
}


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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int a, w = 0;
	for(int i=0; i<n; i++) {
		cin>>a;
		if((i+1)%2 && a%2)
			w++;
	}
	cout<<w;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  int q,h,s,d;
  ll n = 0;
  cin >> q >> h >> s >> d >> n;
  int l2 = 0;
  int l1 = 0;
  l2 = min(d,s * 2);
  l2 = min(l2,h * 4);
  l2 = min(l2,q * 8);
  l1 = min(s,2 * h);
  l1 = min(l1,4 * q);
  ll res = 0;
  if(n % 2 == 0)res = n / 2 * l2;
  else res = n / 2 * l2 + l1;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

same = 0
for i in range(N):
    for j in range(1, N):
        if i+j*2 > N-1:
            break
        if S[i] != S[i+j] and S[i] != S[i+j*2] and S[i+j] != S[i+j*2]:
            same += 1

cnt = {'R': 0, 'G': 0, 'B': 0}
for c in S:
    cnt[c] += 1

print(cnt['R'] * cnt['G'] * cnt['B'] - same)


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int n, x = 0, max = 0;
    string s;
    cin >> n >> s;
    rep(i, n)
    {
        ((s[i] == 'I') ? (x++) : (x--));
        if (max < x)
        {
            max = x;
        }
    }
    cout << max << endl;
    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 Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

ll gcd(ll a,ll b){
  if(b<a) return gcd(b,a);
  if(b%a==0) return a;
  return gcd(b%a,a);
}

int main(){
  ll n;cin>>n;
  ll x;cin>>x;
  ll g[n];
  ll a;
  rep(i,n){
    cin>>a;
    a-=x;
    if(a>=0) g[i]=a;
    else g[i]=(-1)*a;
  }
  a=g[0];
  
  rep(i,n){
    a=gcd(a,g[i]);
  }
  
  cout<<a<<endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }


signed main()
{
	int n, a;
	cin >> n >> a;
	cout << (n * n) - a << endl;
}



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

int main()
{
  int n, m;
  int c[21], t[50001];

  cin >> n >> m;
  for (int i = 0; i < m; i++){
    cin >> c[i];
  }

  fill(t, t + 50001, 1 << 29);
  t[0] = 0;
  for (int i = 0; i < m; i++){
    for (int j = 0; j + c[i] <= n; j++){
      t[j + c[i]] = min(t[j + c[i]], t[j] + 1);
    }
  }
  cout << t[n] << endl;
}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,r,x,y,z,ans=-INF,ans2=0,count;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
cin >> a >> b >> c >>d;
  if(b<=0&&d<=0){
  cout <<a*c;
    return 0;
  }if(a>=0&&c>=0){
  cout <<b*d;
    return 0;
  }
  cout << max(a*c,max(max(a*d,c*b),b*d));
  return 0;
for(LL i=a;i<=b;i++){
  for(LL j=c;j<=d;j++){
    ans=max(ans,i*j);
  }
}
cout << ans;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main() {
    int N, X, Y;
    scanf("%d %d %d", &N, &X, &Y);
    int count[N];
    for(int i = 0; i < N; ++i){
        count[i] = 0;
    }
    for(int i = 1; i <= N; ++i){
        for(int j = i + 1; j <= N; ++j){

            if(j - i >= (abs(X - i) + 1 + abs(j - Y))){
                count[abs(X - i) + 1 + abs(j - Y)] ++;
            }
            else{
                count[j- i]++;
            }
        }
    }

    for(int i = 1; i < N; ++i){
        printf("%d\n",count[i]);
    }


    return 0;
}
int A(){
    char Word[256];
    scanf("%s",&Word);
    if(Word[2]==Word[3] && Word[4] == Word[5]){
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}

int B(){
    long long int money;
    scanf("%lld",&money);
    long long int happy1000;
    long long int happy5;
    happy1000 = money /500 ;
    happy5 = (money % 500) / 5;

    printf("%lld",happy1000*1000+happy5*5);
    return 0;
}

int C(){
    int K;
    int N;
    scanf("%d %d",&K,&N);
    int A[N+1];
    int max = 0;

    for(int i = 0; i < N; ++i){
        scanf("%d",&A[i]);
    }
    A[N] = A[0] + K;

    for(int i = 1; i <= N; ++i){
        if(A[i]-A[i-1] >= max){
            max = A[i]-A[i-1];
        }
    }
    printf("%d",K-max);
    return 0;
}

int floid_warshall(){
    int N, X, Y;
    scanf("%d %d %d", &N, &X, &Y);
    int DP[N + 1][N + 1];
    int count[N];
    int node[N + 1][N + 1];

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= N; ++j) {
            node[i][j] = 2000;
            DP[i][j] = 2000;
        }
    }
    for (int i = 1; i < N; ++i) {
        count[i] = 0;
        node[i][i] = 0;
        node[i][i + 1] = 1;
        node[i + 1][i] = 1;
    }
    node[X][Y] = 1;
    node[Y][X] = 1;

    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= N; ++j){
            for(int k = 1; k <= N; ++k){
                if(node[j][k] > node[j][i] + node[i][k]){
                    node[j][k] = node[j][i] + node[i][k];
                }
                else{
                    node[j][k] = node[j][k];
                }
            }
        }
    }

//    for (int i = 1; i <= N; ++i) {
//        for (int j = 1; j <= N; j++) {
//            printf("%d\t",node[i][j]);
//        }
//        printf("\n");
//    }
    for(int i = 1; i <=N; ++i) {
        for (int j = i + 1; j <= N; ++j) {
            count[node[i][j]]++;
        }
    }
    for(int i = 1; i <= N - 1; ++i) {
        printf("%d\n", count[i]);
    }
    return 0;
}



Measured memory_bytes: 128
#include <iostream>


using namespace std;

int main() {
	int n, pi_1, pi, pi1, num = 0;
	cin >> n >> pi_1 >> pi >> pi1;
	if (pi < pi1 & pi > pi_1 | pi > pi1 & pi < pi_1)
		num++;
	for (int i = 3; i < n; i++)
	{
		pi_1 = pi, pi = pi1; 
		cin >> pi1;
		if (pi < pi1 & pi > pi_1 | pi > pi1 & pi < pi_1)
			num++;
	}
	cout << num;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace abc127_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var m = CIn.ReadInt();

      var a = new int[n + 1];

      for (var i = 0; i < m; i++)
      {
        a[CIn.ReadInt() - 1]++;
        a[CIn.ReadInt()]--;
      }

      var s = 0;
      var ans = 0;

      for (var i = 0; i < n; i++)
      {
        s += a[i];

        if (s == m) ans++;
      }

      Console.WriteLine(ans);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 15456
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Point{
	double x,y;
};

struct Info{
	Point p1,p2;
};

double calc_len(Info info){
	return sqrt((info.p1.x-info.p2.x)*(info.p1.x-info.p2.x)+(info.p1.y-info.p2.y)*(info.p1.y-info.p2.y));
}

double calc_slope(Info info){
	if(fabs(info.p1.x-info.p2.x) < EPS){
		return DBL_MAX;
	}else{
		return (info.p2.y-info.p1.y)/(info.p2.x-info.p1.x);
	}
}

int main(){

	int N;
	scanf("%d",&N);
	if(N%2 == 1){
		printf("NA\n");
		return 0;
	}

	Info info[N];
	Point point[N];
	scanf("%lf %lf",&info[0].p1.x,&info[0].p1.y);
	point[0].x = info[0].p1.x;
	point[0].y = info[0].p1.y;

	for(int i = 1; i <= N-1; i++){
		scanf("%lf %lf",&info[i-1].p2.x,&info[i-1].p2.y);
		info[i].p1.x = info[i-1].p2.x;
		info[i].p1.y = info[i-1].p2.y;

		point[i].x = info[i-1].p2.x;
		point[i].y = info[i-1].p2.y;

	}
	info[N-1].p2.x = info[0].p1.x;
	info[N-1].p2.y = info[0].p1.y;

	bool FLG = true;

	for(int i = 0; i < N/2; i++){
		if(calc_len(info[i]) != calc_len(info[i+N/2])){
			FLG = false;
			break;
		}
		if(calc_slope(info[i]) != calc_slope(info[i+N/2])){
			FLG = false;
			break;
		}
	}

	if(FLG){
		printf("%.10lf %.10lf\n",(point[0].x+point[N/2].x)/2.0,(point[0].y+point[N/2].y)/2.0);
	}else{
		printf("NA\n");
	}

	return 0;
}

Measured memory_bytes: 3204
#encoding: utf-8

n, mod = int(input()), 10 ** 9 + 7


memo = [{} for i in range(n + 1)]

def check(last):
    for i in range(4):
        t = list(last)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if "".join(t).count("AGC") >= 1:
            return 0
    return 1

def dfs(cnt, last):
    if last in memo[cnt]:
        return memo[cnt][last]
    if cnt == n:
        return 1
    ret = 0
    for c in "ACGT":
        if check(last + c):
            ret = (ret + dfs(cnt + 1, last[1:] + c)) % (10 ** 9 + 7)
    memo[cnt][last] = ret 
    return ret 

print(dfs(0, "TTT"))

Measured memory_bytes: 3872
N = int(input())
d = {}
dmax = 1
for i in range(N):
  s = input()
  if s in d:
    d[s] += 1
    if dmax < d[s]:
      dmax = d[s]
  else:
    d[s] = 1

dd = []
for k,v in d.items():
  if v == dmax:
    dd.append(k)

dd.sort()
for dv in dd:
  print(dv)


Measured memory_bytes: 32096
#include <cstdio>
#include <queue>
#include <bitset>
using namespace std;

bitset <100> maskdiv[100], full, invmaskdiv[100];
int n;
vector <int> a;
long long ans=0ll;
void bruteForcePrune(long long potential, long long curr=0ll, bitset <100> currmask=full, int pos=1){
	if(potential<=ans)
		return;
	if(pos==n){
		ans=curr;
		return;
	}
	if(!currmask[pos]){
		return bruteForcePrune(potential, curr, currmask, pos+1);
	}
	if(a[pos]>=0){
		return bruteForcePrune(potential, curr+a[pos], currmask, pos+1);
	}
	bruteForcePrune(potential+a[pos], curr+a[pos], currmask, pos+1);
	bitset <100> toDelete=currmask&maskdiv[pos];
	for(int i = pos+1;i < n;i ++){
		if(toDelete[i]){
			if(a[i]>0){
				potential-=a[i];
			}
		}
	}
	return bruteForcePrune(potential, curr, currmask&invmaskdiv[pos], pos+1);
}
int main(){
	full.set();
	for(int i = 0;i < 100;i ++){
		for(int j = i+1;j <= 100;j += i+1){
			maskdiv[i][j-1]=true;
		}
		invmaskdiv[i]=~maskdiv[i];
	}
	scanf("%d", &n);
	a.resize(n);
	long long fullPotential=0ll;
	for(int&i:a){
		scanf("%d", &i);
	}
	for(int i = 1;i < n;i ++){
		fullPotential+=max(a[i], 0);
	}
	bruteForcePrune(fullPotential);
	printf("%lld\n", max(ans+a[0], 0ll));
}

Measured memory_bytes: 3264
#ABC128-B
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
d=dict()
for i in range(n):
    s,p=SL()
    if s in d:
        d[s].append([int(p),i+1])
    else:
        d[s]=[[int(p),i+1]]
k=list(d.keys())
k.sort()
for key in k:
    t=d[key]
    t.sort(reverse=True)
    for p,num in t:
        print(num)

Measured memory_bytes: 38612
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

N,M=map(int, input().split())

AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[0])
A = [ab[0] for ab in AB]
B = [ab[1] for ab in AB]
Bd = [B[0]] + [B[i+1]^B[i] for i in range(N-1)] + [B[N-1]]

import bisect
E=[set() for _ in range(N+1)]
for i in range(M):
    L,R=map(int, input().split())
    l = bisect.bisect_left(A, L)
    r = bisect.bisect_right(A, R)
    E[l].add((r, i+1))
    E[r].add((l, i+1))

used = [False for _ in range(N+1)]
ans = []
def dfs(x):
    used[x] = True
    rslt = Bd[x]
    for to,i in E[x]:
        if used[to]: continue
        r = dfs(to)
        if r: ans.append(i)
        rslt ^= r
    return rslt

for i in range(N+1):
    if used[i]: continue
    r = dfs(i)
    if r:
        print(-1)
        exit()

print(len(ans))
print(' '.join(map(str, sorted(ans))))

Measured memory_bytes: 177500
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int a[n];
	int cnt[n + 1] = {0};
	for(int i = 0; i < n - 1; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		cout << cnt[i] << endl;
	}

	return 0;
}

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

using namespace std;

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

  int s = N / 1000;
  int s_num = s * 1000;
  int h = (N - s_num) / 100;
  int h_num = h * 100;
  int t = (N - s_num - h_num) / 10;
  int t_num = t * 10;
  int o = N - s_num - h_num - t_num;

  if ((s == h && s == t) || (h == t && h == o)) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  typedef long long ll;
int main()
{
      int n;
      double s=0;
      cin>>n;
   for(int i=0;i<n;i++)
      {
            int a;
            cin>>a;

            s+=(1.0/a);
      }
      cout<<1/s<<endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
//use std::collections::HashSet;
// use std::cmp::*;
use std::collections::*;

const MOD: i64 = 1_000_000_007_i64;
fn main() {
    input! {
       H:usize,W:usize,K:Usize1
    }
    if W == 1 {
        println!("1");
        return;
    }
    // ある高さhで、 wとw+1の間を移動した時、
    // 0..w-1の間とw+2..Wの間の棒の存在は自由。
    // 同様に、移動しなかった時
    // 0..w-1の間とw+1..Wの間の棒の存在は自由
    // 縦棒は高々8本。
    let mut free_bars = HashMap::new();
    let fib = |x| match x {
        0 => 1,
        1 => 1,
        2 => 2,
        3 => 3,
        4 => 5,
        5 => 8,
        6 => 13,
        7 => 21,
        8 => 34,
        _ => 1,
    };
    for w in 0..W {
        // w -> w
        free_bars.insert((w, w), fib(w) * fib(W - w - 1));
        if w < W - 1 {
            free_bars.insert((w, w + 1), fib(w) * fib(W - w - 2));
        }
    }
    // 以上、準備
    // 縦棒がW本なので、隙間はW-1かしょ。
    // 上から h cm の位置で、移動前後の位置をペアで表す。
    // H回の遷移で、0からKまで移動する必要がある。
    let mut mv = vec![(0, 0); H];
    // 通過するバーを下記のように表す。
    let mut l = vec![vec![0; W]; H];
    // h 回目の移動後に位置wにいるパターン数をdpとする。
    let mut dp = vec![vec![0; W]; H];
    dp[0][0] = *free_bars.get(&(0, 0)).unwrap();
    dp[0][1] = *free_bars.get(&(0, 1)).unwrap();
    for h in 1..H {
        for w in 0..W {
            if w > 0 {
                dp[h][w] += dp[h - 1][w - 1] * *free_bars.get(&(w - 1, w)).unwrap();
            }
            dp[h][w] += dp[h - 1][w] * *free_bars.get(&(w, w)).unwrap();
            if w < W - 1 {
                dp[h][w] += dp[h - 1][w + 1] * *free_bars.get(&(w, w + 1)).unwrap();
            }
            dp[h][w] = dp[h][w] % MOD;
        }
    }
    //println!("{:?}", dp);
    println!("{}", dp[H - 1][K]);
}


Measured memory_bytes: 2204
#include<stdio.h>
int main()
{
	int a,b,c,n,i;
	while (scanf("%d",&n)!=EOF)
	{
		for (i=0;i<n;i++)
		{
			scanf("%d%d%d",&a,&b,&c);
			if (a+b<=c||b+c<=a||a+c<=b)
				printf("NO\n");
			else if ((a*a+b*b-c*c)==0||(b*b+c*c-a*a)==0||(c*c+a*a-b*b)==0)
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using GraphC = vector<vector<char>>;

int main() {
  int H, W;
  cin >> H >> W;
  GraphC g(H, vector<char>(W));
  rep(y, 0, H) rep(x, 0, W) cin >> g[y][x];

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

  int cnt = 0;
  rep(y, 0, H) {
    rep(x, 0, W) {
      if (g[y][x] != '#') continue;
      int nextIsNotBlack = 0;
      rep(i, 0, 4) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
        if (g[ny][nx] != '#') nextIsNotBlack++;
      }
      if (nextIsNotBlack == 4) cnt++;
    }
  }

  if (cnt == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;

const lli mod = 1000000007LL;
const int MAXN = 200005;
lli F[MAXN];

int bit[MAXN], n;

int sum(int i){
  ++i;
  int s = 0;
  while(i > 0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i, int x){
  ++i;
  while(i <= n){
    bit[i] += x;
    i += i & -i;
  }
}

int main() {
  F[0] = 1;
  for(lli i = 1; i < MAXN; ++i) F[i] = F[i-1] * i % mod;

  int N, R;
  while(cin >> N && N) {
    cin >> R;
    vector<int> v(N);
    for(int i = 0; i < N; ++i) v[i] = i;
    for(int i = 0; i < R; ++i) {
      int s, t;
      cin >> s >> t;
      swap(v[s-1], v[t-1]);
    }
    n = N;
    fill(bit, bit+MAXN, 0);
    for(int i = 0; i < N; ++i) add(i, 1);
    lli res = 0;
    for(int i = 0, j = N-1; i < N; ++i, --j) {
      lli rank = sum(v[i]) - 1;
      add(v[i], -1);
      res = (res + rank * F[j]) % mod;
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3924
N = int(input())
S = [[-1 for i in range(N)] for j in range(N)]

for i in range(N):
  A = int(input())
  for a in range(A):
    x, y = map(int, input().split())
    S[i][x - 1] = y
ans = 0
for i in range(2**N):
  H = [0 for _ in range(N)]
  for _ in range(N):
    if i>>_ &1:
      H[_] = 1
  f = True
  for j in range(N):
    if H[j]:
      for k in range(N):
        if S[j][k] == -1:
          continue
        elif S[j][k] != H[k]:
          f = False
  if f:
    ans = max(ans, H.count(1))
print(ans)

Measured memory_bytes: 3064
import java.awt.geom.Point2D;
import java.util.*;


public class Main {
		Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ1186();
	}
	
	class problem_A{
		public problem_A() {
//			Scanner in = new Scanner(System.in);
			int n = in.nextInt();
			int[] list = new int[n];
			for(int i=0;i<n;i++)list[i] = in.nextInt();
			Arrays.sort(list);
			
		}
	}
	
	class AOJ1186{
		ArrayList<Object> list; 
		final int N = 150*150;
		public AOJ1186() {
			list = new ArrayList<Object>();
			for(int i=1;i<=150;i++)for(int s=i+1;s<=150;s++)list.add(new Object(i, s));
			Collections.sort(list);
			while(true){
				int h = in.nextInt();
				int w = in.nextInt();
				if(h+w==0)break;
				doIt(h, w);
			}
		}
		void doIt(int h,int w){
			for(int i=0;i<list.size();i++)if(list.get(i).h==h&&list.get(i).w==w){
				System.out.println(list.get(i+1).h+" "+list.get(i+1).w);
				break;
			}
		}
	}
	class Object implements Comparable<Object>{
		int h,w;
		int diagonal;
		public Object(int h,int w) {
			this.h = h;
			this.w = w;
			diagonal = h*h+w*w;
		}
		public int compareTo(Object o) {
			if(this.diagonal>o.diagonal)return 1;
			else if(this.diagonal<o.diagonal)return -1;
			else if(this.h>o.h)return 1;
			else if(this.h<o.h)return -1;
			return 0;
		}
	}
	
}

Measured memory_bytes: 32708
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long P = 10^^9+7;
long[10^^5+50] F, RF;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

long inv(long x)
{
    return pow(x, P-2);
}

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

long comb(N)(N n, N k)
{
    if (k > n) return 0;
    auto n_b = F[n];    // n!
    auto nk_b = RF[n-k]; // 1 / (n-k)!
    auto k_b = RF[k];    // 1 / k!

    auto nk_b_k_b = (nk_b * k_b) % P; // 1 / (n-k)!k!

    return (n_b * nk_b_k_b) % P;  // n! / (n-k)!k!
}
void main()
{
    init();
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    auto as = readln.split.to!(long[]);
    sort(as);
    if (N == K) {
        writeln(as[$-1] - as[0]);
        return;
    }
    long r;
    foreach (i, a; as) {
        if (i >= K-1) r = (r + (comb(i.to!long, K-1) * a) % P) % P;
        if (N-i-1 >= K-1) r = (r - (comb((N-i-1).to!long, K-1) * a) % P + P) % P;
    }
    writeln(r);
}

Measured memory_bytes: 6008
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll l, r, d;
  cin >> l >> r >> d;
  
  ll ans = 0;
  for (int i = l; i < r + 1; i++){
    if (i % d == 0)
      ans++;
  }
  cout << ans << endl;

  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    ll a[100002];
    ll copy[100002];
    vector<int> v;
    ll lar = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        copy[i] = a[i];
        if(a[i] > lar){
            lar = a[i];
            v.push_back(i);
        }
    }
    sort(copy, copy + n);
    ll ans[100002] {0};
    int now = 0;
    for(int i = 0; i < n; i++){
        if(copy[i] <= a[v[now]]){
            if(now == 0) ans[v[now]] += copy[i];
            else ans[v[now]] += copy[i] - a[v[now - 1]];
        }
        else{
            if(now == 0) ans[v[now]] += (n - i) * a[v[now]];
            else ans[v[now]] += (n - i) * (a[v[now]] - a[v[now - 1]]);
            now++;
            i--;
        }
    }
    for(int i = 0; i < n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 3960
n,m=map(int,input().split())
l=[]
for i in range(n):
    l.append(list(input()))
k=[]
for i in range(m):
    k.append(list(input()))
f=0
for i in range(n-m+1):
    for j in range(n-m+1):
        t=0
        for p in range(m):
            for q in range(m):
                if k[p][q]==l[i+p][j+q]:
                    t+=1
        if t==m*m:
            f+=1
if f>0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
// Date: 2020-03-14

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

LL dp[22][1<<21];
int a[22][22], n;
VI g[N];

void add(LL& x, LL y) { x = (x + y) % mod; }

int main() {
    cin >> n;
    rep(i, 1, n) rep(j, 1, n) {
        cin >> a[i][j];
        if(a[i][j]) g[i].pb(j);
    }
    dp[0][0] = 1;
    int up = (1 << n) - 1;
    rep(i, 0, n-1) rep(j, 0, up) {
        if(dp[i][j]) {
            for(auto v : g[i+1]) if(!(j >> (v-1) & 1)) add(dp[i+1][j | (1<<(v-1))], dp[i][j]);
        }
    }
    cout << dp[n][up];


    return 0;
}

Measured memory_bytes: 313600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    vector<ll> T(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
    ll lcm = T[0];
    if (N > 1) {
        lcm = T[0] / __gcd(T[0], T[1]) * T[1];
    }
    for (int i = 2; i < N; i++) {
        lcm = lcm / __gcd(lcm, T[i]) * T[i];
    }

    cout << lcm << endl;
    return 0;
}

Measured memory_bytes: 256
#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;


P a[3000];
bool used[3000];
int root[3000];
priority_queue<int,vector<int>,greater<int>>dat[3000];
vector<int>dat2[3000];

void merge(int u,int v){
	u=root[u];v=root[v];
	if(u==v)return;
	if(dat2[u].size()<dat2[v].size())swap(u,v);
	while(!dat[v].empty()){
		int p=dat[v].top();dat[v].pop();
		dat[u].push(p);
	}
	for(int i:dat2[v]){
		root[i]=u;
		dat2[u].push_back(i);
	}
}

int main(){
	//O(Nlog^2N)
	int n,K,q;cin>>n>>K>>q;
	rep(i,n){
		scanf("%d",&a[i].first);
		a[i].second=i;
	}
	rep(i,n){
		root[i]=i;
		dat[i].push(a[i].first);
		dat2[i].push_back(i);
	}
	sort(a,a+n,greater<>());
	priority_queue<int>que;
	int ans=INT_MAX;
	rep(i,n){
		P p=a[i];
		used[p.second]=true;
		if(p.second&&used[p.second-1]){
			merge(p.second-1,p.second);
		}
		if(p.second+1<n&&used[p.second+1]){
			merge(p.second+1,p.second);
		}
		while(dat[root[p.second]].size()>=K){
			int r=dat[root[p.second]].top();dat[root[p.second]].pop();
			que.push(r);
		}
		while(que.size()>q)que.pop();
		if(que.size()==q){
			ans=min(ans,que.top()-p.first);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
// キュー
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<limits.h>

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>

//const int MAX_N = 100000;
const int STR_LEN = 10;

// キュー関連の定義
const int Max_Queue = 100000;

// キューの要素の構造体
typedef struct q_e
{
    // 配列の要素No.
    int id;
    // プロセス名
    char process_name[STR_LEN];
    // プロセスの時間
    int process_time;
}queue_element;

queue_element ary_queue[Max_Queue];

// キューの情報の構造体
typedef struct q_i
{
    int top;
    int tail;
    int count;
}queue_info;

queue_info que_info;

void create_queue(void);
int enqueue(queue_element element);
queue_element dequeue(void);

int main(void)
{

    int N, cpu_time, total_time = 0;
    char str[STR_LEN];
    queue_element que_ele;

    // キューの初期化
    create_queue();

    scanf("%d %d", &N, &cpu_time);

    for(int i = 0; i < N; i++)
    {
    	que_ele.id = i;

        scanf("%s", &str[0]);
        strcpy(&(que_ele.process_name[0]), &str[0]);

        scanf("%s", &str[0]);
        que_ele.process_time = atoi(str);

        // キューに挿入する
        enqueue(que_ele);
    }

    // cpuの時間を割り当てる
    while( que_info.count > 0 )
    {
        // キューからポップする
        que_ele = dequeue();

        if( 0 < que_ele.process_time
            && que_ele.process_time <= cpu_time )
        {
            total_time += que_ele.process_time;
            que_ele.process_time = 0;

            printf("%s %d\n", que_ele.process_name, total_time);
        }
        else
        {
            total_time += cpu_time;
            que_ele.process_time -= cpu_time;

            enqueue(que_ele);
        }
    }

    return 0;

}

// キューを作成する関数
void create_queue(void)
{
    int i;

    for(i = 0; i < Max_Queue; i++)
    {
        // キューの初期化
    	ary_queue[i].id = 0;
        ary_queue[i].process_name[0] = '\0';
        ary_queue[i].process_time = 0;
    }

    que_info.top = 0;
    que_info.tail = 0;
    que_info.count = 0;

    return;
}

// キューへプッシュする関数
int enqueue(queue_element element)
{

    if( que_info.count > Max_Queue )
    {
        // サイズオーバー
        return INT_MIN;
    }

    if( que_info.tail == Max_Queue - 1 )
    {
        // 配列をラウンド型にする
        que_info.tail = -1;
    }

    // キューに追加する
    ary_queue[que_info.tail++] = element;
    que_info.count++;

    return 0;
}

// キューからポップする関数
queue_element dequeue(void)
{
    queue_element ret;

    if( que_info.count < 0 )
    {
        // キューが空の時
        ret.id = INT_MIN;
    }
    else
    {
        if( que_info.top == Max_Queue - 1 )
        {
            // 配列をラウンド型にする
            que_info.top = -1;
        }

        ret = ary_queue[que_info.top++];
    }

    que_info.count--;

    return ret;
}



Measured memory_bytes: 5148
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  string S;cin>>S;
  bool okk=true;
  rep(i,26){
    bool ok=false;
    rep(j,S.size()){
      if(S[j]==alp[i]){
        ok=true;
      }
    }
    
    if(!ok){cout<<alp[i]<<endl;okk=false;break;}
  }
  if(okk){
   cout<<"None"<<endl;
  }
}







Measured memory_bytes: 512
#include <cstdio>
#include <map>
#include <vector>
using namespace std;
using ll = long long int;

const int SIZE = 1 << 18;
struct segtree {
    vector<ll> node;
    segtree() {
        node = vector<ll>(2*SIZE);
    }
    void update(int x) {
        x += SIZE - 1;
        node[x]++;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = node[2*x+1] + node[2*x+2];
        }
    }
    ll query(int a, int b, int l=0, int r=SIZE, int k=0) {
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        int mid = (l + r) / 2;
        ll vl = query(a, b, l, mid, 2*k+1);
        ll vr = query(a, b, mid, r, 2*k+2);
        return vl + vr;
    }
};

segtree seg;
int main() {
    ll N, K; scanf("%lld%lld", &N, &K);
    ll sum = 0;

    vector<ll> A(N);
    map<ll, int> comp;
    comp[0] = 0;
    for(int i=1; i<=N; i++) {
        ll val; scanf("%lld", &val);
        sum += val;
        A[i-1] = sum - i*K;
        comp[ A[i-1] ]++;
    }

    int idx = 0;
    for(auto &x : comp) {
        x.second = idx++;
    }

    ll ans = 0;
    seg.update( comp[0] );
    for(int i=0; i<N; i++) {
        int k = comp[ A[i] ];
        ans += seg.query(0, k+1);
        seg.update(k);
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
using namespace std;
 
int mod = 1e9 + 7;
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; i++) cin >> h[i];
	
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1];
}

Measured memory_bytes: 4368
#include "bits/stdc++.h"
using namespace std;
#ifdef ONLINE_JUDGE
#define trace(...)
#endif

using LL = long long;

void answer(vector<int> vec) {
	if (vec.empty()) {
		cout << "-1\n";
	} else {
		cout << vec.size() << '\n';
		for (int x: vec) {
			cout << (x + 1) << '\n';
		}
	}
	exit(0);
}

const int N = 1000;
vector<int> adj[N];
bool mat[N][N];

int vis[N];
vector<int> cycle;
int stop = -1;

bool dfs(int u) {
	if (vis[u] == 2) return false;
	if (vis[u] == 1) {
		stop = u;
		return true;
	}
	vis[u] = 1;
	for (int v: adj[u]) {
		if (dfs(v)) {
			if (stop != -1) cycle.push_back(u);
			if (stop == u) stop = -1;
			return true;
		}
	}
	vis[u] = 2;
	return false;
}

bool valid[N];

bool simplify() {
	const int len = cycle.size();
	const int u = cycle[0];
	if (valid[u]) return false;
	for (int j = 2; j + 1 < len; j++) {
		const int v = cycle[j];
		if (mat[v][u]) {
			cycle.resize(j + 1);
			break;
		}
		if (mat[u][v]) {
			cycle.erase(cycle.begin() + 1, cycle.begin() + j);
			break;
		}
	}
	valid[u] = true;
	return true;
}
void show() {
	return;
	cerr << ">>>> ";
	for (int u: cycle) cerr << (u+1) << ' ';
	cerr << endl;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m; cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v; u--, v--;
		adj[u].push_back(v);
		mat[u][v] = true;
		if (mat[u][v] && mat[v][u]) {
			answer({u, v});
		}
	}

	for (int u = 0; u < n; u++) {
		if (vis[u] != 0) continue;
		cycle.clear();
		stop = -1;
		if (dfs(u)) {
			reverse(cycle.begin(), cycle.end()); show();
			while (simplify()) {
				cycle.push_back(cycle[0]);
				cycle.erase(cycle.begin());
			}

			answer(cycle);
		}
	}

	answer({});

	return 0;
}


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

int main(){
  
  int N,M;
  cin >> N >> M;
  vector<long long> a(M,0);
  vector<long long> Ans(N+1,-1);

  for(int i = 0; i < M; i++){
    cin >> a.at(i); 
  }

  for(int i = 0; i < M; i++){
    Ans.at(a.at(i)) = 0;
  }

  if(Ans.at(1) != 0){
    Ans.at(1) = 1;
  }

  if(2 <= N){

    if(Ans.at(2) != 0){
    Ans.at(2) = 1;
    Ans.at(2) += Ans.at(1);
  }

  }

  if(3<=N){

  for(int i = 3; i < N+1; i++){
    if(Ans.at(i) != 0){
    Ans.at(i) = (Ans.at(i-1) + Ans.at(i-2))%1000000007;
    }
  }

  }

    cout << Ans.at(N) << endl;

}


Measured memory_bytes: 4732
N = int(input())
A = list(map(int, input().split()))

x = 0
for i in range(N-1):
  x = 2 * A[i] - x

x = (2 * A[-1] - x) // 2
ans = [x]

for i in range(N-1):
  x = 2 * A[i] - x
  ans.append(x)

print(*ans)

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long a, long long b){
	cout << (a <= b ? "unsafe" : "safe") << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 3652
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0]);
  const S = input[1].split('');

  let tmp = '';
  let ret = 0;
  for(let i=0; i<N; i++){
    if(tmp === S[i]){
      ret += 1;
    }
    tmp = S[i];
  }
  console.log(N-ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8268
from math import pi, cos, sin, sqrt

a, b, h, m = map(int, input().split())

theta_a = 2*pi * (h*60 + m) / (12*60)
theta_b = 2*pi * m / 60

[xa, ya] = [a*cos(theta_a), a*sin(theta_a)]
[xb, yb] = [b*cos(theta_b), b*sin(theta_b)]

distance = sqrt((xa - xb)**2 + (ya - yb)**2)
print(distance)

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

vector<vector<int> > check(int n,int cnt)
{
  //  cout<<"start "<<n<<" "<<cnt<<endl;
  vector<vector<int> > ans;
  if(cnt<=0|| n<=0)
    return ans;
  for(;n>0;n--)
    {
      // cout<<"n="<<n<<endl;
      vector<int> tmp;
      tmp.push_back(n);
      if(n==cnt)
	{
	  ans.push_back(tmp);
	  continue;
	}
      vector<vector<int> > buf=check(n,cnt-n);
      for(int i=0;i<buf.size();i++)
	{
	  vector<int> tt=tmp;
	  tt.insert(tt.end(),buf[i].begin(),buf[i].end());
	  ans.push_back(tt);
	}
    }
  return ans;
}

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      vector<vector<int> > ans=check(n,n);
      for(int i=0;i<ans.size();i++)
	{
	  for(int j=0;j<ans[i].size();j++)
	    {
	    cout<<ans[i][j];
	    if(j != ans[i].size()-1)
	      cout<<" ";
	    }
	  cout<<endl;
	}
    }

}

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

int main() {
  char S[3];
  for(int i=0;i<3;i++){
    cin>>S[i];
  }

  if(S[0]==S[1]&&S[1]==S[2]){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }

}


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

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


Measured memory_bytes: 3096
# a.py
# N = int(input()) #ここで標準入力
# # print (type(N),N) 

# print(N*N*N)
#### ##################
# b.py
man=0
N = int(input()) #ここで標準入力
A = [input().split() for i in range(3)]
# print(A)
# B全部たす
for i in range(N):
   man=man+int(A[1][i])
   # if (i!=N):

#例外処理
for i in range(N-1):
   # if(A[0][i]<=A[0][i+1]):    # 食べる順が i -> i+1 の時
   if(int(A[0][i+1]) == int(A[0][i])+1):
      # print(man)
      ryori_i=int(A[0][i])
      man_c=int(A[2][ryori_i-1])
      man=man+man_c
      # print (cn)

print(man)

Measured memory_bytes: 3064