akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            int n = ReadAndParseInt();
            var a = new int[n];
            for(int i=0;i<n;++i)
            {
                a[i] = ReadAndParseInt();
            }


            int pushCnt = 0;
            int lightIdx = 0;
            while(true)
            {
                pushCnt++;
                lightIdx = a[lightIdx] - 1;
                
                if( lightIdx == 1)
                {
                    break;
                }
                if (pushCnt >= n)
                {
                    break;
                }
            }

            if(pushCnt == n)
            {
                pushCnt = -1;
            }
            Console.WriteLine(pushCnt);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

int main(){
    int n;
    cin >> n;
    if(n<=111) cout << 111 << endl;
    if(n>111&&n<=222) cout << 222 << endl;
    if(n>222&&n<=333) cout << 333 << endl;
    if(n>333&&n<=444) cout << 444 << endl;
    if(n>444&&n<=555) cout << 555 << endl;
    if(n>555&&n<=666) cout << 666 << endl;
    if(n>666&&n<=777) cout << 777 << endl;
    if(n>777&&n<=888) cout << 888 << endl;
    if(n>888&&n<=999) cout << 999 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    while(n>0){
		solve();
		n--;
	    }
	}
    }

    static void solve(){
	String order = kbd.next();
	String message = kbd.next();
	String[] m = new String[message.length()];
	String[] os = new String[order.length()];

	int i;
	for(i=0; i<message.length(); i++){
	    m[i] = message.substring(i, i+1);
	}

	for(i=0; i<order.length(); i++){  
	    os[i] = order.substring(i, i+1);
	}

	for(i=os.length-1; i>=0; i--){
	    change(m, os[i]);
	    /*
	    for(int j=0; j<m.length; j++){
		System.out.print(m[j]);
	    }
	    System.out.println();
	    */
	}
	
	String ans = "";
	for(i=0; i<m.length; i++){
	    ans += m[i];
	}
	System.out.println(ans);
    }

    static void change(String[] m, String os){
	int i;
	//左ずらし
	//"J"がやらかす間違い、"C"の訂正に使える
	if(os.equals("C")){
	    String a = m[0];
	    for(i=0; i<m.length-1; i++){
		m[i] = m[i+1];
	    }
	    m[m.length-1] = a;
	}
	//右ずらし
	//"C"がやらかす間違い、"J"の訂正に使える
	else if(os.equals("J")){
	    String a = m[m.length-1];
	    for(i=m.length-1; i>0; i--){
		m[i] = m[i-1];
	    }
	    m[0] = a;
	}
	//半分入れ替え
	else if(os.equals("E")){
	    int middle = m.length/2;
	    String[] r = new String[middle];
	    String[] l = new String[middle];
	    if(m.length%2==1){
		for(i=0; i<middle; i++){
		    r[i] = m[i];
		    l[i] = m[middle+i+1];
		}
		for(i=0; i<middle; i++){
		    m[i] = l[i];
		    m[middle+i+1] = r[i];
		}
	    }
	    else{
		for(i=0; i<middle; i++){
		    r[i] = m[i];
		    l[i] = m[middle+i];
		}
		for(i=0; i<middle; i++){
		    m[i] = l[i];
		    m[middle+i] = r[i];
		}
	    }
	}
	//反転
	else if(os.equals("A")){
	    for(i=0; i<(m.length)/2; i++){
		String w = m[i];
		m[i] = m[m.length-i-1];
		m[m.length-i-1] = w;
	    }
	}
	//数字なら1足す
	//"P"がやらかす間違い、"M"の訂正に使える。
	else if(os.equals("M")){
	    for(i=0; i<m.length; i++){
		if(isN(m[i])){
		    int n = (Integer.parseInt(m[i])+1)%10;
		    m[i] = Integer.toString(n);
		}
	    }
	}
	//数字なら1引く
	//"M"がやらかす間違い、"P"の訂正に使える。
	else if(os.equals("P")){
	    for(i=0; i<m.length; i++){
		if(isN(m[i])){
		    int n = (Integer.parseInt(m[i])-1+10)%10;
		    m[i] = Integer.toString(n);
		}
	    }
	}
    }

    static boolean isN(String s){
	if(s.equals("1")) return true;
	else if(s.equals("2")) return true;
	else if(s.equals("3")) return true;
	else if(s.equals("4")) return true;
	else if(s.equals("5")) return true;
	else if(s.equals("6")) return true;
	else if(s.equals("7")) return true;
	else if(s.equals("8")) return true;
	else if(s.equals("9")) return true;
	else if(s.equals("0")) return true;
	else return false;
    }
}

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

int main(){
  int n;
  cin >> n;
  if (n % 10 ==2 || n % 10 ==4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9){
    cout << "hon" << endl;
  }
  else if ( n % 10 == 3){
    cout << "bon" << endl;
  }
  else {
    cout << "pon" << endl;
  }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
long long s,n,i,j,a,b,o[1000000]= {1,1},k[1000009];
int main() {
	for(i=2; i<sqrt(100000); i++)
		for(j=i*2; j<100000; j+=i)
			o[j]=1;
	for (int i=1; i<=100000; i++) {
		if(o[i]==0 && o[(i+1)/2]==0 && i!=2) {
			k[i]=k[i-1]+1;
		}
		else k[i]=k[i-1];
	}
	cin>>n;
	for(int i=0; i<n; i++) {
		cin>>a>>b;
		cout<<k[b]-k[a-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <assert.h>
 
#define int          long long
#define pb          push_back
#define pii         pair<int,int> 
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007 
#define mem(x)      memset(x,0,sizeof(x));
#define what_is(x)  cout << #x << " is " << x << flush << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
 
using namespace std;
const int maxn = 200010;
int n;
long double x, dp[maxn];
void solve(){
	cin>>n;
	dp[0] = 1;
	rep(coins, 0, n)
	{
		cin>>x;
		for(int i = coins+1; i>=0; i--)
			dp[i] = (i == 0 ? 0 : x * dp[i-1]) + (1-x)*dp[i];
	}
	long double ans = 0;

	rep(heads, n/2+1, n+1)
	{
		ans+= dp[heads];
	}
	cout<<setprecision(10)<<ans;

	



}
 
signed main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
     //cin>>t;
 
    while(t--)
        solve();
    
    return 0;
}

Measured memory_bytes: 384
import java.io.*;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = in.readLine();
		boolean n = false, s = false, e = false, w = false, answer = false;
		if (line.contains("N"))
			n = true;
		if (line.contains("S"))
			s = true;
		if (line.contains("E"))
			e = true;
		if (line.contains("W"))
			w = true;
		if (n && s && e && w)
			answer = true;
		else if (n && s && e == false && w == false)
			answer = true;
		else if (e && w && n == false && s == false)
			answer = true;

		if (answer)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	double sum = 0;
	for (int i = 0; i < n; i++) sum += 1.0 / ri();
	
	printf("%.11f\n", 1.0 / sum);
	
	return 0;
}


Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

LL s;
int main()
{
  scanf("%lld",&s);
	LL sq=sqrt(s);
	while(sq*sq<s)sq++;
	LL rest=sq*sq-s;
	printf("0 0 %lld %lld %lld %lld\n",sq,rest,1,sq);
	return 0;
}

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

int main(void) {
    int A,B;cin>>A>>B;
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible"  << endl;
    return 0;   
}

Measured memory_bytes: 760
#include<stdio.h>
int main(void)
{
	int N,L,i;
	int sum=0;
	scanf("%d%d",&N,&L);
	for(i=1;i<N;i++)
	{
		
		if(L<=0)
		{
			sum=L+i-1+sum;
		}
		else if(L>0)
		{
			sum=L+i+sum;
		}
		if(L+i-1==0)
		{
			N=N+1;
		}
	}
	printf("%d",sum);
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;

int main() {
    int a,b;
    cin >> a >> b;
    if (a<b) swap(a,b);
    rep(i,a) cout << b;
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		if(a<b)
		{
			if(b<c)
			{
				System.out.println(a+" "+b+" "+c);
			}
			else if(c<a)
			{
				System.out.println(c+" "+a+" "+b);
			}
			else
			{
				System.out.println(a+" "+c+" "+b);
			}
		}
		else
		{
			if(a<c)
			{
				System.out.println(b+" "+a+" "+c);
			}
			else if(b>c)
			{
				System.out.println(c+" "+b+" "+a);
			}
			else
			{
				System.out.println(b+" "+c+" "+a);
			}
		}
	}

}

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

int main() {
  string S;
  cin >> S;
  string T = "";
  int pos = 0;
  while(pos < S.length()) {
    if(S[pos] == 'B' && S[pos+1] == 'C') {
      T += 'D';
      pos += 2;
    }
    else {
      T += S[pos];
      pos += 1;
    }
  }
  int64_t ans = 0;
  int64_t Anum = 0;
  for(int i = 0; i < T.length(); i++) {
    if(T[i] == 'A') {
      Anum++;
    }
    else if(T[i] == 'D') {
      ans += Anum;
    }
    else {
      Anum = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <list>
#include <cmath>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 100000;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ LL to, cost; edge(int t, LL c) :to(t), cost(c){} };

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

int bitcount(int a)
{
	int ret = 0;
	while (a != 0) { ret++; a = (a - 1) & a; }
	return ret;
}

int dp[151][1001][77];
int stage[151][1001];

int main()
{
	int n, m;
	while (cin >> n >> m && n)
	{
		rep(i, n) rep(j, 1001) stage[i][j] = INF;
		int width = 0;
		rep(i, n)
		{
			int num; cin >> num;
			rep(j, num)
			{
				int idx, slip; cin >> idx >> slip;
				width = max(width, idx);
				stage[i][idx - 1] = slip;
			}
		}
		rep(i, n + 1) rep(j, width) rep(k, m + 1) dp[i][j][k] = INF;
		rep(i, width) dp[0][i][0] = stage[n][i] = 0;
		if (m > 0)
		{
			rep(i, width) dp[1][i][1] = 0;
		}
		rep(i, n)
		{
			rep(j, width) if (stage[i][j] < INF)
			{
				rep(l, m + 1) if (dp[i][j][l] < INF)
				{
					rep(k, width)
					{
						dp[i + 1][k][l] = min(dp[i + 1][k][l], dp[i][j][l] + (stage[i][j] + stage[i + 1][k]) * abs(j - k));
						if (i + 2 <= n)
							dp[i + 2][k][l + 1] = min(dp[i + 2][k][l + 1], dp[i][j][l] + (stage[i][j] + stage[i + 2][k]) * abs(j - k));
					}
				}
			}
		}
		int ans = INF;
		rep(i, width) rep(j, m + 1) ans = min(ans, dp[n][i][j]);
		cout << ans << endl;
	}

	return 0;
}

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

#define um unordered_map
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sc static_cast

#define has(a, b) (a.find(b) != a.end())
#define all(x) (x).begin(), (x).end()
#define maxval(t) numeric_limits<t>::max()
#define minval(t) numeric_limits<t>::min()
#define imin(a,b) a = min(a,b)
#define imax(a,b) a = max(a,b)
#define fora(i, n) for(int i = 0; i < n; i++)
#define forb(i, n) for(int i = 1; i <= n; i++)
#define forc(a, b) for(const auto &a : b)
#define ford(i, l, r) for(int i = l; i <= r; i++)
#define fore(i, n) for(int i = n-1; i >= 0; --i)
#define pvec(v) copy(all(v), ostream_iterator<decltype(v)::value_type>(cout, " "))

#define dbgs(x) #x << " = " << x
#define dbgs2(x, y) dbgs(x) << ", " << dbgs(y)
#define dbgs3(x, y, z) dbgs2(x, y) << ", " << dbgs(z)
#define dbgs4(w, x, y, z) dbgs3(w, x, y) << ", " << dbgs(z)

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vii;
typedef vector<vll> vlll;
typedef um<int,int> umii;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

void display (const vector<vector<int> >& vy) {  
    fora(i, (int) vy.size()) {
        fora(j, (int) vy[i].size()) cout << vy[i][j] << " ";
        cout << endl;
    }
}

ll power(ll a, ll n) {
     if (n == 0) return 1;
     ll x = power(a, floor(n/2));
     if (n & 1) return a*x*x;
     else return x*x;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);   
    double n, d; cin >> n >> d;

    cout << ceil(n / (d*2+1)) << "\n";
    return 0;
}



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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(N > 2 && M > 2){
			Console.WriteLine((N-2) * (M-2));
			return;
		}
		
		if(N == 1 && M == 1){
			Console.WriteLine(1);
			return;
		}
		if(N == 1 && M == 2){
			Console.WriteLine(0);
			return;
		}
		if(N == 1){
			Console.WriteLine(M - 2);
			return;
		}
		if(N == 2){
			Console.WriteLine(0);
			return;
		}
		
		
		
	}
	long N,M;
	public Sol(){
		var d = rla();
		N = d[0]; M = d[1];
		if(N > M){
			var t = N; N = M; M = t;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();
    int n = sc.nextInt();
    int a = 1;

    for (int i = 0; i < d; i++) {
      a *= 100;
    }

    if (n == 100) {
      System.out.println(a * (n+1));
      return;
    }

    System.out.println(a * n);
  }
}


Measured memory_bytes: 23380
n,m=map(int,input().split())
G=[[0]*n for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  G[a-1][b-1]=G[b-1][a-1]=1

from itertools import permutations
ans=0
p=list(permutations([x for x in range(1,n)]))
for pp in p:
  ok=True
  t=[0]+list(pp)
  for i in range(1,n):
    if G[t[i-1]][t[i]]==0:
      ok=False
  if ok:ans+=1
print(ans)


Measured memory_bytes: 9304
/*
    In the name of
        "ALLAH"
    And say "AL-HAM-DU-LILLAH"
*/

#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long

int take() {
    int n;
    scanf("%d",&n);
    return n;

}
double ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define Int take()
#define Dnt ttake()
#define LL takes()
#define done {return 0;}
#define fr(n) for(int i=1;i<=n;i++)
#define FR(a,b,x) for(int i=(a);i<=(b);i+=(x))
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define vii vector<pii>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)

using namespace std;

bool approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define STR {struct info}
#define dbg(x) {cout<<"ekhane"<<x<<endl;}
#define  SS second
#define  FF first
#define PQ priority_queue
#define great greatest
#define less lesser
#define mii map<int,int>
#define mil map<int,ll>
#define mll map<ll,ll>
#define msb map<string,bool>
#define M 100005
//////////////////////////////////////////


int main(){

   int a=Int,b=Int;
   vi d;
   while(b){
    d.pb(b%10);
    b/=10;
   }
   for(int i=d.size()-1;i>=0;i--) a=a*10+d[i];

   int p=ceil(sqrt(a));
   if(p*p==a) printf("Yes\n");
   else printf("No\n");

    done;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static ArrayList<trip> ll;
    public static void main(String[] args){
        try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int n=Integer.parseInt(ss[0]);
            int x=Integer.parseInt(ss[1]);
            ss=br.readLine().split(" ");
            int[] arr=new int[n];
            int sum=0;
            int c=0;
            for(int i=0;i<n;i++){
                arr[i]=Integer.parseInt(ss[i]);
                sum+=arr[i];
                if(sum<=x){
                    c++;
                }
            }
            System.out.println(c+1);

        }catch(Exception e){
            System.out.println("KKKK "+e.getMessage());
        }
    }

    static class trip{
        int lev,node,child;
        public trip(int lev,int node,int child){
            this.lev=lev;
            this.node=node;
            this.child=child;
        }
    }
    static void bfs(ArrayList<ArrayList<Integer>> list){
        Queue<trip> q=new ArrayDeque<>();
        q.add(new trip(0,0,list.get(0).size()));
        boolean[] brr=new boolean[list.size()];
        brr[0]=true;
        while(q.size()>0){
            trip t=q.poll();
            if(t.child==0) {
                ll.add(t);
            }

            int node=t.node;
            for(int i=0;i<list.get(node).size();i++){
                int u=list.get(node).get(i);
                if(!brr[u]){
                    q.add(new trip(t.lev+1,u,list.get(u).size()));
                    brr[u]=true;
                }
            }
        }
    }
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define Fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define deb(x) cout<<#x<<" "<<x<<endl;
#define all(v) v.begin(),v.end()
#define endl '\n'
using namespace __gnu_pbds;
using namespace std;

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

void judge() {
#ifndef ONLINE_JUDGE
	FILE_READ_IN
	FILE_READ_OUT
#endif
}
const int N = 2e5 + 1;
int a[N];
int n;
int k;

bool fun(int m) {
	int val = 0;
	for (int i = n - 1; i >= 0; i--) {
		int x = a[i];
		int r = 1;
		int y = 0;
		while (x > m) {
			y += r;
			x++;
			x /= 2;
			r *= 2;
		}
		val += min(y, a[i] / m);
		// cout<<m<<" "<<a[i]<<" "<<r/2<<endl;
	}
	// cout << val << endl;
	if (val <= k)return true;
	return false;
}

int main() {
	Fast;
	int t = 1;
	judge();
	// cin >> t;
	while (t--) {
		// int n;
		cin >> n >> k;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a, a + n);
		int s = 1, e = a[n - 1];
		int ret = a[n - 1];
		while (s <= e) {
			int m = (s + e) / 2;
			// cout << m << " " ;
			bool ans = fun(m);
			if (ans) {
				ret = m;
				e = m - 1;
			}
			else {
				s = m + 1;
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 4368
#include <stdio.h>
main()
{
    long long int n,m,a[100];
	int i,j=0,k=0;

	scanf("%lld",&n);
	m=n;
	
    while(n!=0)
	{
	        k++;
		n=n/10;
	}
    n=m;
    for(i=0;i<k;i++)
	{
		a[i]=n%10;
		j=j+a[i];
		n=n/10;
	}
    if((m%j) == 0)
	{
		printf("Yes\n");
	}
    else
	{
		printf("No\n");
	}

    return 0;
}

Measured memory_bytes: 128
H, N = [int(s) for s in input().split()]
dec = []
cost = []
for i in range(N):
    a, b = [int(s) for s in input().split()]
    dec.append(a)
    cost.append(b)
bar = ((H-1)//dec[0]+1)*cost[0]
memo = [bar]*(H+1)
memo[0] = 0
for h in range(1,H+1):
    for i in range(N):
        memo[h] = min(memo[h], memo[max(0,h-dec[i])]+cost[i])
print(memo[H])

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var cin = GetStrArray();
            var ans = cin[0] == cin[1] ? "H" : "D";

            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, m, p[1000];
int main() {
	while (true) {
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0) break;
		for (int i = 0; i < n; i++) scanf("%d", &p[i]);
		sort(p, p + n);
		int ret = 0;
		for (int i = 0; i < n; i++) ret += p[i];
		for (int i = n % m; i + m <= n; i += m) ret -= p[i];
		printf("%d\n", ret);
	}
	return 0;
}

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

typedef long long LL;
const int M=2e5+5;

int cnt[M];

// Ai+Aj=j-i
// Ai+i = j-Aj

int main()
{
	int n; scanf("%d",&n);
	int ai;
	LL ans=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&ai);
		if(ai<=i)
			ans+=cnt[i-ai];
		if(ai+i<M)
			cnt[ai+i]++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4564
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        ArrayList<Integer> list = new ArrayList<>();
        for( int i = 0; i < 10; i++ ) {
            list.add( Integer.parseInt(br.readLine()) );
        }
        Collections.sort(list, Collections.reverseOrder());
        for( int i = 0; i< 3; i++  ) {
            System.out.println( list.get(i) );
        }
    }
}



Measured memory_bytes: 24356
#include <stdio.h>
int main(){
  int x, y, tmp;
  while(1){
  scanf("%d%d", &x, &y);
  if(x == 0 && y == 0){
   break;
  } else if(x > y){
    tmp = x; x = y; y = tmp;
  }
      printf("%d %d\n", x, y);
  }
  return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> K(N+1);
  for(int i=0; i<M; i++){
    int L, R;
    cin >> L >> R;
    K.at(L-1)++;
    K.at(R)--;
  }
  int ans=0;
  int sum=0;
  for(int i=0; i<N+1; i++){
    sum+=K.at(i);
    if(sum==M) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
from bisect import bisect_right

N, M = map(int, input().split())
*A, = map(int, input().split())
INF = 10**12
A.sort()
ac = [0]*(N+1)
for i in range(1, N+1):
    ac[i] = ac[i-1]+A[i-1]

def f(x):
    v = 0
    for i in A:
        v += N-bisect_right(A, x-i)
    return v

def g(l):
    ans = INF
    for i in A:
        res = bisect_right(A, l-i)
        if 0<=res<N:
            ans = min(ans, A[res]+i)
    return ans

l, r = 0, INF+1
while r-l>1:
    m = (l+r)//2
    if f(m)>=M:
        l = m
    else:
        r = m

ans = 0
for i in A:
    v1 = N-bisect_right(A, r-i)
    ans += ac[N]-ac[N-v1]+v1*i
ans += (M-f(r))*g(l)

print(ans)

Measured memory_bytes: 89068
def submit():
    n, k = map(int, input().split())
    hlist = list(map(int, input().split()))

    if k >= n:
        print(0)
        return

    if k == 0:
        print(sum(hlist))
        return

    hlist.sort()
    print(sum(hlist[:-k]))


if __name__ == "__main__":
    submit()

Measured memory_bytes: 26024
from collections import Counter
from collections import deque
from functools import reduce
from operator import mul
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def COMBINATION(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    o = reduce(mul, range(n, n - r, -1))
    u = reduce(mul, range(1, r + 1))
    return o // u
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


n = II()
h = LI()
for i in range(n):
    if i == 0:
        h[i] -= 1
        continue
    if h[i-1] < h[i]:
        h[i] -= 1
    if h[i-1] > h[i]:
        print('No')
        exit()
print('Yes')


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> k;
  --k;
  int s[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << s[k] << '\n';
  return 0;
}


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

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
R = 0
B = 0
G = 0
for i in range(N):
    if S[i] == 'R':
        R += 1
    elif S[i] == 'G':
        G += 1
    else:
        B += 1
ans = R*G*B
for i in range(N):
    for j in range(i+1,N):
        k = 2*j-i
        if k >= N:
            continue
        elif S[i]!= S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1

print(ans)

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int n;
  cin>>n;
  ll A[n];
  rep(i,n)
    cin>>A[i];
  sort(A,A+n);
  cout<<A[n-1]-A[0]<<endl;



  return 0;
}


Measured memory_bytes: 256
from collections import deque


def main():
    N = int(input())

    av = ord('a')

    def to_s(ary):
        ans = "".join(map(lambda v: chr(v + av), ary))
        return ans

    def search(i, v, ary):
        if i == N:
            print(to_s(ary))
            return

        for u in range(0, v + 2):
            ary[i] = u
            search(i + 1, max(u, v), ary)

    ary = [0] * N
    search(0, -1, ary)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4720
N = int(input())
A = list(map(int, input().split()))
MOD = 10 **9 + 7
 
ni = [0 for _ in range(60)]
for i in range(N):
    tmp = A[i]
    count = 0
    while(True):
        if tmp % 2 == 1:
            ni[count] += 1
        count += 1
        tmp = tmp // 2
        if tmp == 0:
            break
ans = 0
for j in range(60):
    ans += (ni[j] * (N-ni[j])) * 2 ** j 
 
print(ans%MOD)

Measured memory_bytes: 122808
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b


a, b = input().split()
c = a + b
c = int(c)

if int(math.sqrt(c)) * int(math.sqrt(c)) == c:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12380
/*
 * Matheus Oliveira
 * 08:40:36 12/04/2020
 * a.cpp
*/

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

#define EPS
#define INF
#define MAXN
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define sc(x) scanf("%d", &x);
#define sc2(x, y) scanf("%d %d", &x, &y);
#define sc3(x, y, z) scanf("%d %d %d", &x, &y, &z);
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, bg, ed) printf("%s: ", #x); for(int i = bg; i < ed; i++) printf("%d%c", x[i], (i == ed-1) ? '\n' : ' ');

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

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

	bool ok = false;
	
	for(int i = 0; i < (int)n.size(); i++) {
		if(n[i] == '7') ok = true;
	}

	if(ok) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int N, v, cnt = 0;
    
    cin >> N;
    for ( int i = 0; i < N; i++ ) {
        cin >> v;
        while( v%2==0) {
            cnt++;
            v /= 2;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
 // freopen("input.txt","r",stdin);
#endif

  int n,m;
  cin>>n>>m;
  ll sum=0;
  for(int i=0;i<m;i++)
  {
    int x;
    cin>>x;
    sum+=x;
  }

  if(sum>n)
  {
    cout<<-1<<endl;
  }
  else
  {
    cout<<n-sum<<endl;
  }

  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    double p = -1.0;
    int ws = 0, s = 0;
    for (int i = 0; 100 * A * i <= F; i++) {
        for (int j = 0; 100 * B * j <= F - 100 * A * i; j++) {
            int water = 100 * (i * A + j * B);
            int limit = min(F - water, water / 100 * E);
            int sugar = 0;
            for (int k = 0; k * C <= limit; k++) {
                for (int l = 0; l * D <= limit - k * C; l++) {
                    if (k * C + l * D > sugar) sugar = k * C + l * D;
                }
            }
            if (water + sugar > 0 && (double)sugar / (water + sugar) > p) {
                p = (double)sugar / (water + sugar);
                ws = water + sugar;
                s = sugar;
            }
        }
    }
    cout << ws << " " << s << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    B = il()

    ret = 0
    for n in range(N):
        if B[n] >= A[n]+A[n+1]:
            ret += A[n] + A[n+1]
            A[n+1] = 0
        elif B[n] >= A[n]:
            ret += B[n]
            A[n+1] -= B[n] - A[n]
        else:
            ret += B[n]

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18744
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def io_generator():
	return input()

def iil(a_io):
	return map(int, a_io().split())


#+++++++++++++++++++



def main(io):
	n,m =iil(io)
	aas=list(iil(io))
	bbs=[]
	for _ in range(m):
		b,c=iil(io)
		bbs.append((b,c))
		
	
	aas.sort()
	#print(aas)
	bbs=sorted(bbs, key=lambda t:-t[1])
	#print(bbs)
	bbii=0
	bbij=0
	ret=0
	ddd=0
	for i in aas:
		if ddd ==1:
			ret += i
			continue
			
		if i > bbs[bbii][1]:
			ret += i
			ddd=1
			continue
			
		ret += bbs[bbii][1]
		
		bbij+=1
		if bbij >= bbs[bbii][0]:
			bbij=0
			bbii+=1
		
		if bbii >= len(bbs):
			ddd=1
	return ret
			
			
		
	
	return

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	ret = main(io)
	if ret is not None:
		print(ret)

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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
//typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n,k;
vector<int> G[2010];
vector<pair<int,int>> P;
bool used[2010];
pair<int,int> no;

int dfs(int v, int d) {
  if (used[v]) return 0;
  used[v] = 1;
  int ans = (d > k / 2);
  for (int i = 0; i < G[v].size(); i++) {
    if ((v == no.fi && G[v][i] == no.se) || (v == no.se && G[v][i] == no.fi)) continue;
    ans += dfs(G[v][i], d + 1);
  }
  return ans;
}

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

  cin >> n >> k;
  REP(i,n-1) {
    int a,b;
    cin >> a >> b;
    G[a].pb(b);
    G[b].pb(a);
    if (a > b) swap(a,b);
    P.pb({a,b});
  }

  int ans = inf;
  if (k&1) {
    REP(i,n-1) {
      REP(j,2010) used[j] = 0;
      no = P[i];
      ans = min(ans, dfs(no.fi,0) + dfs(no.se,0));
    }
  } else {
    REP(i,n) {
      REP(j,2010) used[j] = 0;
      ans = min(ans, dfs(i+1,0));
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define cost(i,j) abs(h[i]-h[j])
using namespace std;
int n,k;
int h[100001],dp[100001];
int main()
{
    cin>>n>>k;
    for(int i=2;i<=n;i++)
        dp[i]=1<<30;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=((i+k<=n)?i+k:n);j++)
            dp[j]=min(dp[j],dp[i]+cost(i,j));
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin >> s;

    if(c < d){
        bool flag = true;
        FOR(i,a + 1,d){
            if(s[i] == '#' and s[i + 1] == '#') flag = false;
        }
        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        bool flag1 = true;
        FOR(i,a + 1,c){
            if(s[i] == '#' and s[i + 1] == '#') flag1 = false;
        }
        if(not flag1){
            cout << "No" << endl;
            return 0;
        }       

        bool flag2 = false;

        FOR(i,b-1,d) if(s[i] != '#' and s[i+1] != '#' and s[i+2] != '#') flag2 = true;
        if(flag2) cout << "Yes" << endl;
        else cout << "No" << endl; 
    }
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  ll r = 0;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i) continue;
    if (i - 1 && n / (i - 1) == n % (i - 1)) r += i - 1;
    if (i * i != n && n / (n / i - 1) == n % (n / i - 1)) r += n / i - 1;
  }
  cout << r << endl;
}


Measured memory_bytes: 256
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))
S.append(0)
ans = 0
for i in T:
  S[n] = i
  j = 0
  while S[j] != i:
    j+=1
  if j!=n:
    ans+=1
print(ans)  


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

int main(void)
{
	long long	K, N/*, A[1000000 * 2]*/;
	long long max = 0, current = 0, distance = 0;
	vector<long long> A(100000 * 2);

	cin >> K >> N;
	rep(i, N) {
		cin >> A[i];
		distance = A[i] - current;
		if (max < distance) {
			max = distance;
		}
		current = A[i];
	}
	distance = (A[0] + K) - current;
	if (max < distance) {
		max = distance;
	}

	cout << K - max << endl;

	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 深さ優先探索
vector<bool> seen;
vector<int> block;

int block_count;

void dfs(const Graph &G, int v, int color) {
    block_count++;
    seen[v] = true;
    block[v] = color;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v, color); // 再帰的に探索
    }
}
int main()
{
    int N, M, K;
    cin >> N >> M >> K;

    // グラフ
    Graph G(N);
    Graph H(N);

    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    vector<int> C(K);
    vector<int> D(K);
    REP(i, K){
        int c, d;
        cin >> c >> d;
        C[i] = c-1;
        D[i] = d-1;
    }
    // 全頂点が訪問済みになるまで探索
    int count = 0;
    int total_count = 0;
    seen.assign(N, false);
    block.assign(N, 0);
    vector<int> block_sum(N);
    for (int v = 0; v < N; ++v) {
        if (seen[v]){
            block_sum[v] = block_sum[block[v]];
            continue; // v が探索済みだったらスルー
        }
        block_count = 0;
        dfs(G, v, v); // v が未探索なら v を始点とした DFS を行う
        ++count;
        block_sum[v] = block_count -1;
        block_count = 0;
    }
    vector<int> minus_count(N, 0);
    for(int j=0; j<K; j++){
        if(block[C[j]] == block[D[j]]){
            minus_count[C[j]]++;
            minus_count[D[j]]++;
        }
    }
    REP(i, N){
        if(i != N-1){
            cout << block_sum[i] - G[i].size() - minus_count[i] << " ";
        }
        else{
            cout << block_sum[i] - G[i].size() - minus_count[i] << endl;
        }
        // cout << minus_count << endl;
    }
    // cout << D[0];
    return 0;
}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b , c , d;
  int left, right;
  
  cin >> a >> b >> c >>d;
  
  left = a + b ;
  right = c + d ;
  
  if ( left > right ) {
    cout << "Left" << endl;
  } else if ( left < right ) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int a,b;
int main(){
	scanf("%d%d", &a, &b);
	if(a<b) swap(a,b);
	rep(i,a) printf("%d", b);
	puts("");
}

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

/* clang-format off */
// #define int long long
// #define double long double
struct Fast {Fast() {cin.tie(0); ios::sync_with_stdio(false);}} fast;

template <typename T> inline size_t maxElement(T beginIt, T endIt) { return max_element(beginIt, endIt); }
template <typename T> inline size_t minElement(T beginIt, T endIt) { return min_element(beginIt, endIt); }
template <typename T> inline size_t maxIndex(T beginIt, T endIt) { return distance(beginIt, *max_element(beginIt, endIt)); }
template <typename T> inline size_t minIndex(T beginIt, T endIt) { return distance(beginIt, *min_element(beginIt, endIt)); }
template <typename T> inline int sum(T beginIt, T endIt) { return accumulate(beginIt, endIt, 0); }
template <typename T> inline int mean(T beginIt, T endIt) { return sum(beginIt, endIt) / distance(beginIt, endIt); }
template <typename T> inline void debug(T x) { cerr << x << " " << "(L:" << __LINE__ << ")" << endl; }
/* clang-format on */

signed main(void) {
  /* */
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  // double num; // num
  // num = 0; // count, result
  // num = numeric_limits<double>::min(); // max
  // num = numeric_limits<double>::max(); // min
  int N, M;
  array<int, 100000> A;
  string S, T;
  /* */

  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  num = max({A1, A2, A3}) - min({A1, A2, A3});
    
  cout << num << endl;
  // cout << fixed << setprecision(10) << num << endl;
  return 0;
}


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

int main() {
	
	int a, b;
	cin >> a >> b;
	
	if(a < b) swap(a, b);
	rep(i, a) cout << b;
	cout << endl;
	return 0;
}

Measured memory_bytes: 256