akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 1; j <= k; j++) {
			if (i + j == n)
				break ;
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i+j]));
		}
	}
	cout << dp[n-1] << endl;
}



Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Linq;
using System.IO;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
#if DEBUG
            ReadLine();
#endif
        }


        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            List<Tuple<int, int>> ans = new List<Tuple<int, int>>();

            for (int i = 1; i <= n; i++)
            {
                for (int j = i + 1; j <= n; j++)
                {
                    if (n - i + ((n + 1) % 2) != j)
                    {
                        ans.Add(new Tuple<int, int>(i, j));
                    }
                }
            }

            Console.WriteLine(ans.Count);
            for (int i = 0; i < ans.Count; i++)
                Console.WriteLine(ans[i].Item1 + " " + ans[i].Item2);
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}

Measured memory_bytes: 13380
#include <cstdio>
using namespace std;
int main(){
	int a,b,c,k;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	for(; b<=a; b<<=1,--k);
	for(; c<=b; c<<=1,--k);
	puts(k>=0?"Yes":"No");
	return 0;
}

Measured memory_bytes: 1624
#include<bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define ss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;

int main()
{
    int a[6];

    Rep(i,1,5)
    {
        si(a[i]);
    }


    Rep(i,1,5)
    {
        if(!a[i])
        {
            printf("%d\n",i);
            break;
        }
    }


    return 0;
}


Measured memory_bytes: 3828
#include <stdio.h>

int map_size;
char map[1000][1001];
int map_ruiseki[1000][1000];

int is_ok(int y,int target) {
	int i;
	int now_renzoku;
	now_renzoku=0;
	for(i=0;i<map_size;i++) {
		if(map_ruiseki[y][i]>=target)now_renzoku++;
		else now_renzoku=0;
		if(now_renzoku>=target)return 1;
	}
	return 0;
}

int main(void) {
	int i,j;
	int now;
	int left,right,mid;
	int result;
	while(1) {
		scanf("%d",&map_size);
		if(map_size==0)break;
		for(i=0;i<map_size;i++)scanf("%s",map[i]);
		for(i=0;i<map_size;i++) {
			now=0;
			for(j=0;j<map_size;j++) {
				if(map[j][i]=='*')now=0; else now++;
				map_ruiseki[j][i]=now;
			}
		}
		result=0;
		for(i=0;i<map_size;i++) {
			left=result;right=map_size;
			while(left<=right) {
				mid=(left+right)/2;
				if(is_ok(i,mid))left=mid+1;
				else right=mid-1;
			}
			if(left-1>result)result=left-1;
		}
		printf("%d\n",result);
	}
	return 0;
}

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


#define li          int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li a[111];
li b[111];

int main() {
    cin>>n;
    rin{
        cin>>a[i]>>b[i];
    }

    rep(i,n-2){
        if(a[i]==b[i] &&
            a[i+1]==b[i+1]&&
            a[i+2]==b[i+2]){
            puts("Yes");
            return 0;
        }
    }
    puts("No");


    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define LL long long
#define PB push_back
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int ob = (mod + 1) >> 1;

int main()
{
	LL a , b, c;
	cin >> a >> b >> c;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
	{
		cout << 0;
		return 0;
	}
	cout << min(a * b , min(b * c , a * c));
}




Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

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

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
const double EPS = 1e-7;
const double MAX = 1000 + 5;


int main() {
	int n, s;
	cin >> n >> s;

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

	vector<vector<int>> dp(n + 1, vector<int>(s + 1));
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		

		for (int j = 0; j <= s; j++) {
			dp[i + 1][j] = (2 * dp[i][j]) % MOD;
			if (j < a[i]) {
				continue;
			}

			dp[i + 1][j] += dp[i][j - a[i]];
			dp[i + 1][j] %= MOD;
		
			
		}
		/*
		for (int d : dp[i+1]) {
			cout << d << " ";
		}
		cout << endl;
		*/
	}

	cout << dp[n][s] << endl;
}

Measured memory_bytes: 38640
// 課題4_2 AtCoder Beginner Contest 168 C - : (Colon)
 
#include<stdio.h>
#include<math.h>
 
int main(void){
    // 時針の長さlength_h cm,分針の長さlength_min cm,時刻hour:min
    int length_h, length_min, hour, min;
    // 結果の格納ans, 短針と時針の間の角度rad
    double ans, rad;
 
    // length_h, length_min, hour, minを受け取る
    scanf("%d %d %d %d", &length_h, &length_min, &hour, &min);

    // intからdoubleに変換
    length_h = (double)length_h;
    length_min = (double)length_min;
    min = (double)min;
    hour = (double)hour;
 
    // 円周率M_PI
    // (分針)ー(時針)cosなので角度の正負は気にしない
    rad = 2.0 * M_PI / 60.0 * min - 2.0 * M_PI / 12 * (hour + min / 60.0);
    // 余弦定理 ans^2
    ans = length_h * length_h + length_min * length_min - 2.0 * length_h * length_min * cos(rad);
    // 平方根をとる
    ans = sqrt(ans);

    printf("%.20f\n", ans);
    
    return 0;
}

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

int main()
{
    int maxv = 0, sum = 0;

    for(int i = 0; i < 3; i++) {
        int A;
        cin >> A;
        sum += A;
        maxv = max(maxv, A);
    }

    cout << sum - maxv << endl;

    return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;
string a,b,c;

ll mod(ll a)
{
	if(a<inf)return a;
	else 
	return a%inf;
}
 void test_cases()
{

ll a,b;
cin>>a>>b;
if(a==1&&b!=1)cout<<"Alice";
else if(a!=1&&b==1)cout<<"Bob";
else if(a>b)
{
cout<<"Alice";	
}
else if(a<b)
{
	cout<<"Bob";
}
else
cout<<"Draw";
}


int main()
{
    fast;
  ll t;
 // cin>>t;
 t=1;
  while(t--)
  test_cases();

  	
}

		
	
	
	
	


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b,n,ans,temp;
    cin >> a >> b >> n;
    ans = -1;
    if(n >= b-1){
        temp = a * (b-1) / b - a * ((b-1) / b);
    }
    else{
        temp = a * (n) / b - a * ((n) / b);
    }
  ans = temp;
    cout << ans << endl;
    
}

Measured memory_bytes: 3600
n,k = map(int, input().split())
p = list(map(int, input().split()))

ev = [0] * n

for i in range(n):
    ev[i] = (1+p[i])/2

cs = [0] * n
cs[0] = ev[0]

for i in range(1,n):
    cs[i] = cs[i-1] + ev[i]

ans = cs[k-1]

for i in range(n-k):
    s = cs[i+k] - cs[i]
    if s > ans:
        ans = s

print(ans)

Measured memory_bytes: 25604
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,j,n,m) for(int i=j;i<n;i+=m)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

ll d[MAXn];
int main(){
  IOS();
  ll n;
  cin>>n;
  REP(i,n) cin>>d[i];
  sort(d,d+n);
  cout<<d[n-1]-d[0]<<endl;
}


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

class Main {

	private static final int NO_DATA = -1;

	public static void main(String[] args) {

		// ストリームを作成する
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));

		while (true) {
			// 入力値を受け取り、合計を数値にして返す
			int sum = getSum(reader);
			// 入力がない場合は終了
			if (sum == NO_DATA) {
				return;
			}
			// 桁数を出力する
			System.out.println(String.valueOf(sum).length());
		}
	}

	/**
	 * ストリームから1行読み込んで、2つの数値を合計して返す。 値が取得できなかった場合は-1を返す。
	 *
	 * @param reader
	 *            入力ストリーム
	 * @return 数値の合計
	 */
	private static int getSum(BufferedReader reader) {
		int result = NO_DATA;
		try {
			String line = reader.readLine();
			if (line == null || line.length() == 0) {
				return result;
			}
			String[] numArray = line.split(" ");
			result = Integer.parseInt(numArray[0])
					+ Integer.parseInt(numArray[1]);
		} catch (IOException e) {
			throw new RuntimeException();
		}
		return result;
	}
}

Measured memory_bytes: 17000
function Main(input) {
  input=input.split("\n");
  var S=input[1];
  var array;
  var flg=false;
  ["S","W"].forEach(a=>{
    ["S","W"].forEach(b=>{
      array=new Array(S.length);
      array[0]=a;
      array[1]=b;
      for(var i=2;i<S.length;i++){
        if(array[i-1]==="W"^S[i-1]==="o"){
          array[i]=array[i-2];
        }else{
          if(array[i-2]==="W"){
            array[i]="S";
          }else{
            array[i]="W";
          }
        }
      }
      //console.log(array.join(""));
      //console.log(array[0]==="S");
      //console.log(S[0]==="o");
      //console.log(array[array.length-1]===array[1]);
      //console.log(array[0]==="S"^S[0]==="o"^array[array.length-1]===array[1]);
      //console.log(array[array.length-1]==="S"^S[array.length-1]==="o"^array[array.length-2]===array[0]);
      if(!flg&&(array[0]==="S"^S[0]==="o"^array[array.length-1]===array[1])&&(array[array.length-1]==="S"^S[array.length-1]==="o"^array[array.length-2]===array[0])){
         console.log(array.join(""));
         flg=true;
      }
    });
  });
  if(!flg)console.log(-1);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


Measured memory_bytes: 38260
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,m,sum=0;
    cin>>n>>m;
    ll arr[n+5];
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    ll x=ceil((sum/(4.0*m)));
    for(ll i=0;i<n;i++)
    {
        if(arr[i]>=x)m--;
        if(m==0)
           {
               cout<<"Yes\n";
                return 0;
           }
    }
    cout<<"No\n";
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

type IsLand map[int][]int

var (
	n        int
	lands    = make(IsLand)
	visited  = make(map[int]bool)
	maxDepth = 2
	POSSIBLE bool
)

func main() {
	n = readInt()
	m := readInt()

	for i := 0; i < m; i++ {
		a := readInt()
		b := readInt()
		lands[a] = append(lands[a], b)
	}

	dfs(1, 1)
	if POSSIBLE {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}

func dfs(p, depth int) {
	if depth >= 3 {
		return
	}
	visited[p] = true
	dests, ok := lands[p]
	if !ok {
		return
	}
	for _, d := range dests {
		if visited[d] {
			continue
		}
		if d == n {
			POSSIBLE = true
		}
		dfs(d, depth+1)
	}
}

/*-------------------inputs-------------------*/

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func subL(list []int) []int {
	sl := make([]int, len(list)-1)
	for i := range list {
		if i == len(list)-1 {
			continue
		}
		sub := list[i+1] - list[i]
		sl[i] = sub
	}
	return sl
}

/*-------------------init-------------------*/

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}


Measured memory_bytes: 21376
from itertools import accumulate


def get_primes_til(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** .5) + 1):
        if is_prime[i]:
            for j in range(2 * i, n + 1, i):
                is_prime[j] = False
    return {i for i in range(2, n + 1) if is_prime[i]}


N_MAX = 10 ** 5
primes = get_primes_til(N_MAX)
is_2017_like = list(accumulate([i in primes and (i + 1) // 2 in primes for i in range(N_MAX + 1)]))
for _ in range(int(input())):
    l, r = map(int, input().split())
    print(is_2017_like[r] - is_2017_like[l - 1])


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

int main() {
    int n, x = 0; cin >> n;
    
    for(int i = 1; i < 50000; i++){
        x = floor(i * 1.08);
        if(x == n){
            cout << i << endl;
            break;
        } else{
            x = 0;
        }
    }
    if(x == 0) printf("%s", ":(");
	return 0;
}

Measured memory_bytes: 256
import sys
inf=1000002
sys.setrecursionlimit(inf)
from collections import deque
h,w,k=map(int,input().split())
x1,y1,x2,y2=map(int,input().split())
c=[input() for i in range(h)]
dp=[[inf if c[i][j]=="." else -1 for j in range(w)] for i in range(h)]
now=deque([[x1-1,y1-1]])
dp[x1-1][y1-1]=0
def bfs(d):
    global dp,now
    l=len(now)
    if l==0:
        return
    dp_sub=deque()
    cand=set()
    for i in range(l):
        x,y=now.popleft()
        for j in range(1,min(k+1,w-y)):
            if dp[x][y+j]==inf:
                dp_sub.append([x,y+j,d])
                cand.add((x,y+j))
            else:
                break
        for j in range(1,min(k+1,y+1)):
            if dp[x][y-j]==inf:
                dp_sub.append([x,y-j,d])
                cand.add((x,y-j))
            else:
                break
        for j in range(1,min(k+1,h-x)):
            if dp[x+j][y]==inf:
                dp_sub.append([x+j,y,d])
                cand.add((x+j,y))
            else:
                break
        for j in range(1,min(k+1,x+1)):
            if dp[x-j][y]==inf:
                dp_sub.append([x-j,y,d])
                cand.add((x-j,y))
            else:
                break
    while dp_sub!=deque([]):
        e=dp_sub.popleft()
        dp[e[0]][e[1]]=e[2]
    for i in cand:
        now.append(i)
    bfs(d+1)
bfs(1)
print(dp[x2-1][y2-1] if dp[x2-1][y2-1]!=inf else -1)

Measured memory_bytes: 1015384
import scala.collection.mutable._
import io.StdIn.readInt
import io.StdIn.readLine

object Main extends App {
  val out = new java.io.PrintWriter(System.out)

  def calculate(q:Array[Int],d:Array[Array[Int]]):Int = {
    val ts = q(0)
    val te = q(1)
    val st = q(2)

    val a = d.filter(_(2) == st)
    val map = new HashMap[Int,Array[Int]]
    val log = ListBuffer.empty[Tuple2[Int,Int]]
    a.foreach(l => {
      if(l(3) == 1) map.put(l(1),l)
      else {
        val e = map.remove(l(1)).get
        log += {( e(0), l(0) )}
        }
    })
    // println(log.mkString)

    val time = Array.ofDim[Boolean](721)
    log.foreach(t => {
      val s = math.max(ts, t._1) -540
      val e = math.min(te, t._2) -540
      (s until e).foreach(time(_) = true)
    })
    time.count(_ == true)
  }

  def solve(s:String):Unit = {
    val Array(n, m) = s.split(" ").map(_.toInt)
    val r = readInt
    val d = Iterator.continually(readLine)
      .take(r)
      .map(_.split(" ").map(_.toInt))
      .toArray
    val q = readInt
    Iterator.continually(readLine)
      .take(q)
      .map(_.split(" ").map(_.toInt))
      .foreach(qd => out.println(calculate(qd,d)))
  }

  Iterator.continually(readLine)
    .takeWhile(_ != "0 0")
    .foreach(solve(_))
  
  out.flush
}


Measured memory_bytes: 57468
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b; cin >> a >> b;
    if(a != 1 && b != 1) cout << 1 << endl;
    if(a != 2 && b != 2) cout << 2 << endl;
    if(a != 3 && b != 3) cout << 3 << endl;
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 1000");
            WillReturn.Add("120");
            WillReturn.Add("100");
            WillReturn.Add("140");
            //9
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 360");
            WillReturn.Add("90");
            WillReturn.Add("90");
            WillReturn.Add("90");
            WillReturn.Add("90");
            //4
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("5 3000");
            WillReturn.Add("150");
            WillReturn.Add("130");
            WillReturn.Add("150");
            WillReturn.Add("130");
            WillReturn.Add("110");
            //26
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(A => int.Parse(A)).ToArray();

        SplitAct(InputList[0]);
        int X = wkArr[1];

        var MList = new List<int>();
        foreach (string EachStr in InputList.Skip(1)) {
            MList.Add(int.Parse(EachStr));
        }

        X -= MList.Sum();
        int Answer = MList.Count();
        Answer += X / MList.Min();

        Console.WriteLine(Answer);
    }
}


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

int main() {
  
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  if(op == '+'){
    
    cout << A + B << endl;
  }
  
  else{
    
    cout << A - B << endl;
    
  }
  
  return 0;
  
}






Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
long long dp[1000][1000];
int mod=1000000007;
char str[2];
int val[1000];
int main(){
	int a;
	scanf("%d",&a);
	int n=0;
	for(int i=0;i<a;i++){
		scanf("%s",str);
		if(str[0]=='U')val[n++]=1;
		if(str[0]=='D')val[n++]=2;
	}
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=i;j++){
			if(val[i]==2){
				dp[i+1][j]=(dp[i+1][j]+dp[i][j]*j)%mod;
				if(j)dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j]*j*j)%mod;
			}else{
				dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod;
				if(j)dp[i+1][j]=(dp[i+1][j]+dp[i][j]*j)%mod;
			}
		}
	}
	printf("%lld\n",dp[n][0]);
}

Measured memory_bytes: 1968
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {
     public static void main(String[] args) {
         FastScanner fs=new FastScanner();
        //  int T=fs.nextInt();
        int T =1 ;
         for (int tt=0; tt<T; tt++) {
             int x = fs.nextInt();
             if(x==0)
             System.out.println(1);
             else
                System.out.println(0);
         }
}
 
 static class FastScanner {
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     StringTokenizer st=new StringTokenizer("");
     String next() {
     while (!st.hasMoreTokens())
         try {
             st=new StringTokenizer(br.readLine());
         } catch (IOException e) {
             e.printStackTrace();
         }
         return st.nextToken();
     }
     
     int nextInt() {
         return Integer.parseInt(next());
     }
     int[] readArray(int n) {
         int[] a=new int[n];
         for (int i=0; i<n; i++) a[i]=nextInt();
         return a;
     }
     long nextLong() {
         return Long.parseLong(next());
     }
 }

 
}


Measured memory_bytes: 32596
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x, i, twodigit, digit, cnt=1, tmp=0, tmp2;
    cin >> x;
    tmp=x;
    if(x<100){
        cout << 0 <<endl;
        return 0;
    }
    if(x>=2000){
        cout << 1 <<endl;
        return 0;
    }
    while(tmp>0){
        tmp2=tmp%10;
        if(cnt<=2){
            if(cnt==1) twodigit=tmp2;
            else twodigit=twodigit+tmp2*10;
        }
        else {
            if(cnt==3) digit=tmp2;
            else digit=digit+tmp2*(cnt-3)*10;
        }
        tmp=tmp/10;
        cnt++;
    }

    if((double)twodigit/digit<=5) cout << 1 <<endl;
    else cout << 0 <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
int main() {
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  vector<int> A(N);
  REP(i,N) cin >> A[i];
  vector<int> tbl(N);
  REP(i,N) {
    int maxVal = A[i], minVal = A[i];
    REP(j,M) {
      maxVal = max(maxVal, A[(i + j) % N]);
      minVal = min(minVal, A[(i + j) % N]);
    }
    tbl[i] = maxVal - minVal;
  }
  int k = 0;
  int ans = 0;
  while(true) {
    ans += tbl[k];
    k += M;
    k %= N;
    if (k == 0) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
    
        int n = Integer.parseInt(sc.next());
        var l = new int[n];
        for(int i = 0; i < n; i++){
            l[i] = Integer.parseInt(sc.next());
        }
    
        int ans = 0;
        for(int a = 0; a < n; a++){
            for(int b = a+1; b < n; b++){
                if(a == b || l[a] == l[b]) continue;
                for(int c = b+1; c < n; c++){
                    if(a == c || b == c || l[a] == l[c] || l[b] == l[c]) continue;
                    
                    if(l[a] + l[b] > l[c] && l[b] + l[c] > l[a] && l[c] + l[a] > l[b]){
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;
using ll = long long;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	int res = 0;
	if (a*a + b*b == c*c) { res = a * b; }
	if (b*b + c*c == a*a) { res = b * c; }
	if (c*c + a*a == b*b) { res = c * a; }

	cout << res / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 200010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

ll a[N], h[N], dp[N], bit[N] ;
int n ;

void add(int x, ll y) {
	for (; x <= n; x += lowbit(x)) bit[x] = max(bit[x], y) ;
}

ll query(int x) {
	ll res = 0 ;
	for (; x; x -= lowbit(x)) res = max(res, bit[x]) ;
	return res ;
}

signed main(){
	scanf("%d", &n) ;
	for (int i = 1; i <= n; i++) scanf("%lld", &h[i]) ;
	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]) ;
	for (int i = 1; i <= n; i++) {
		dp[i] = query(h[i]) + a[i] ;
		add(h[i], dp[i]) ;
	}
	printf("%lld\n", query(n)) ; // all h[i] <= n
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 6528
N = int(input())
primes = [2]
res = []
for i in range(3, 55556):
  p = len(primes)
  f = 1
  for j in range(p):
    if i % primes[j] == 0:
      f = 0
  if f:
    primes.append(i)
    if i % 5 == 1:
      res.append(i)
  if len(res) == N:
    print(*res)
    break

Measured memory_bytes: 3060
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<chrono>
#include<unordered_map>
#include<random>
#include<complex> 
using namespace std;
typedef complex<long double> point;
#define EPS 1e-9 
#define OO 1e9
#define X real()
#define Y imag()
#define vec(a,b) ((b)-(a)) 
#define polar(r,t) ((r)*exp(point(0,(t)))) 
#define angle(v) (atan2((v).Y,(v).X)) 
#define length(v) ((long double)hypot((v).Y,(v).X)) 
#define lengthSqr(v) (dot(v,v)) 
#define dot(a,b) ((conj(a)*(b)).real()) 
#define cross(a,b) ((conj(a)*(b)).imag()) 
#define rotate(v,t) (polar(v,t)) 
#define rotateabout(v,t,a)  (rotate(vec(a,v),t)+(a)) 
#define reflect(p,m) ((conj((p)/(m)))*(m)) 
#define normalize(p) ((p)/length(p)) 
#define same(a,b) (lengthSqr(vec(a,b))<EPS) 
#define mid(a,b) (((a)+(b))/point(2,0)) 
#define perp(a) (point(-(a).Y,(a).X)) 
#define colliner pointOnLine 
enum STATE { IN, OUT, BOUNDRY };

#define ll long long
#define ld long double
#define ull unsigned ll 
#define endl '\n'
#define mk make_pair
#define PI acos(-1.)

void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
int lx[] = { 2, 2, -1, 1, -2, -2, -1, 1 };
int ly[] = { -1, 1, 2, 2, 1, -1, -2, -2 };
const ld eps = 1e-3;
const int N = 5e5 + 50, M = 4e4 + 10, mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll t = gcd(a, b); return t ? (a / t * b) : 0; }
int main() {
	fast_in_out();
	//cout << fixed << setprecision(3);
	int n; cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	int ans = 1e9;
	for (int p = 1; p <= 100; p++) {
		int sum = 0;
		for (auto e : v) {
			sum += ((p - e) * (p - e));
		}
		ans = min(ans, sum);
	}
	cout << ans;
	return 0;


}

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

int main(){
    char s[2000], p[100], tmp[1000];
    scanf("%s", s);
    scanf("%s", p);

    strcpy(tmp, s);
    strcat(s, tmp);
    
    if(strstr(s, p) != NULL) printf("Yes\n");
    else printf("No\n"); 
    
    
    return 0;
}


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

using namespace std;

#define rep(i,m,n) for(int i=m;i<n;i++)


int main(){
 long n,a,b;
   cin >> n >> a >> b;
  vector<long> h(n);
  long hmax=0;
  rep(i,0,n) {
    cin >> h[i];
    hmax=max(hmax,h[i]);
  }
  
  long l=0;
  long r=(hmax-1)/b+1;
  long d=a-b;
  while(l<r){
   long t=(l+r)/2;
    long num=0;
    
    rep(i,0,n){
      long v=h[i]-b*t;
    if(v>0) num+=(v-1)/d+1;
    }
    if(num<=t) r=t;
    else l=t+1;
  
  }
  
   cout << r << endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {
		
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int H = sc.nextInt();
		int W = sc.nextInt();
		int ans = 0;
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				if(i + H <= N && j + W <= N) ans++;
			}
		}
		
		System.out.println(ans);
		
	}//end main
	
}//end Main

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22612
#include <stdio.h>

void push(char);
char pop(char);

char s[100];
int top = 0;

int main(){
  char c[101], x, r[100];
  int i, j, count;
  int ok;
  while(1){
    ok = 1;
    count = 0;
    i = 0;
    top = 0;
    while(1){
      scanf("%c",&c[i]);
      if(c[i] == '\n')
	break;
      i++;
    }


    if(c[0] == '.') break;
    for(i = 0 , j = 0 ; c[i] != '.' ; i++){
      if(c[i] == '(' || c[i] == '[' || c[i] == ')' || c[i] == ']'){
	r[j] = c[i];
	j++;
	count++;
      }
    }
    
    /*    for ( j = 0; j < count; j++ ){
      printf("%c", r[j]);
    }
      printf("\n");
    */
    for(j = 0 ; j < count ; j++){
      if(r[j] == '(' || r[j] == '['){
	push(r[j]);
      } else if(r[j] == ')' || r[j] == ']'){
	if(top == 0){
	  ok = 0;
	  break;
	}
	x = pop(r[j]);
	if((x == '(' && r[j] != ')') || (x == '[' && r[j] != ']')){
	  ok = 0;
	  break;
	}
      }
    }
    if(top != 0)
      ok = 0;


    if ( ok == 1)
      printf("yes\n");
    else 
      printf("no\n");
  }
  return 0;
}
void push(char x){
  top++;
  s[top] = x;
}
char pop(char x){
  x = s[top];
  top--;
  return x;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
const std::string yes = "Yes";
const std::string no  = "No";

long long factrial(long long n){
    long long sum = 1;
    for(int i=1; i<=n; i++) sum *= i;
    return sum;
}

int main(){
    int n; std::cin >> n;
    std::vector<std::pair<int,int>> xy(n);
    rep(i,n) std::cin >> xy[i].first >> xy[i].second;

    std::vector<int> v(n);
    rep(i,n) v[i]=i;

    double ans = 0.0, cnt = 0.0;
    do{
        int x0 = xy[v[0]].first;
        int y0 = xy[v[0]].second;
        int x1 = xy[v[1]].first;
        int y1 = xy[v[1]].second;
        ans += pow((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1),0.5);
        cnt += 1.0;
    }while(std::next_permutation(v.begin(),v.end()));
    cnt /= (n-1);

    std::cout << std::fixed << std::setprecision(10) << ans/cnt << "\n";
    return 0;
}


Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int H,W;
  cin>>H>>W;
  vector<string>a(H);
  for(int i=0;i<H;i++){
    cin>>a[i];
  }
  map<char,int>k;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      k[a[i][j]]++;
    }
  }
  map<int,int>M;
  for(auto c:k){
    M[c.second%4]++;
  }

  bool ok=true;
  if(H%2==0&&W%2==0){
    for(auto c:k){
      if(c.second%4!=0){
        ok=false;
      }
    }
  }
  else if(H%2+W%2==1){
    int even=0;
    if(H%2!=0){even=W;}
    else{even=H;}
    
    if(M[1]||M[3]){ok=false;}
    if(M[2]>even/2){ok=false;}
  }
  else{
    if(M[3]>0){ok=false;}
    if(M[1]!=1){ok=false;}
    if(M[2]>(H-1)/2+(W-1)/2){ok=false;}
  }

  if(ok){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}

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

using namespace std;

#define ll long long

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> numb;
	int i = 2;
	numb.push_back(a%b);
	numb.push_back(-1);
	while(numb[numb.size()-1] != numb[0]){
		numb.push_back((a*i)%b);
		++i;
	}
	bool found = false;
	for(int j = 1; j < (int)numb.size(); ++j){
		if(numb[j] == c) {
			found = true;
			break;
		}
	}
	if(found) cout << "YES";
	else cout << "NO";
	return 0;
}



Measured memory_bytes: 3604
def distance(star, position):
    return sum([(a - b)**2 for a, b in zip(star, position)])**(1 / 2)


def difference(star, position):
    return [(a - b) for a, b in zip(star, position)]


while True:
    n = int(input())
    if n == 0:
        break
    stars = [list(map(float, input().split())) for i in range(n)]
    position = [sum([s[i] for s in stars]) / len(stars) for i in range(3)]
    move_rate = 1
    for i in range(3000):
        if i % 100 == 0:
            move_rate /= 2
        index = 0
        dis_max = 0
        for j, star in enumerate(stars):
            dis = distance(star, position)
            if dis_max < dis:
                dis_max = dis
                index = j
        diff = difference(stars[index], position)
        position = [(position[i] + diff[i] * move_rate) for i in range(3)]

    print(format(dis_max, ".5f"))


Measured memory_bytes: 5736
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
MAX = 60

to = [[0] * (n + 1) for _ in range(MAX)]

to[0] = a

for i in range(1, MAX):
    for j in range(1, n + 1):
        to[i][j] = to[i-1][to[i-1][j]]

v = 1
for i in range(MAX - 1, -1, -1):
    num = 1 << i
    if k >= num:
        v = to[i][v]
        k -= num

print(v)


Measured memory_bytes: 175016
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

int main(){
  int h,w,m; cin >> h >> w >> m;
  set<pii> bomb;
  vector<ll> tate(h);
  vector<ll> yoko(w);
  ll tatemx=0;
  ll yokomx=0;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--; b--;
    tate[a]++; yoko[b]++;
    chmax(tatemx,tate[a]);
    chmax(yokomx,yoko[b]);
    bomb.insert(pii(a,b));
  }
  /*
  ll ans=0;
  rep(i,m){
    chmax(ans,tate[bomb[i].first]+yoko[bomb[i].second]);
  }
  cout << ans-1 << endl;
  */
  vector<int> tatekoho(0);
  vector<int> yokokoho(0);
  rep(i,h){
    if(tate[i]==tatemx) tatekoho.push_back(i);
  }
  rep(i,w){
    if(yoko[i]==yokomx) yokokoho.push_back(i);
  }
  if(tatekoho.size()*yokokoho.size()>m){
    cout << tatemx+yokomx << endl;
    return 0;
  }
  bool f=1;
  rep(i,tatekoho.size()){
    rep(j,yokokoho.size()){
      if(!(bomb.count(pii(tatekoho[i],yokokoho[j])))) f=0;
    }
  }
  if(f) cout << tatemx+yokomx-1 << endl;
  else cout << tatemx+yokomx << endl;
}

Measured memory_bytes: 26100
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<ll> VL;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)

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

  int A, B, C;
  cin >> A >> B >> C;

  if ((A < C && B > C) || (A > C && B < C)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n),b(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	map<int,int> cmp, dmp;
	rep(i,n) {
		cmp[a[i]]++;
		dmp[b[i]]++;
	}
	// 鳩の巣check
	int max=0,maxindex;
	for(auto it=cmp.begin();it !=cmp.end();it++) {
		if (max < it->second){
			max = it->second;
			maxindex = it->first;
		}
	}
	if (max + dmp[maxindex] >= n+1) {
		cout << "No" << endl;
		return 0;
	}
	max = 0;
	for(auto it=dmp.begin();it !=dmp.end();it++) {
		if (max < it->second){
			max = it->second;
			maxindex = it->first;
		}
	}
	if (max + cmp[maxindex] >= n+1) {
		cout << "No" << endl;
		return 0;
	}
	vector<int> c(n+1,0),d(n+1,0);
	for(int i=1;i<=n;i++) {
		c[i] = cmp[i]+c[i-1];
		d[i] = dmp[i]+d[i-1];
	}
	int mx=0;
	rep(i,n+1) {
		if (mx < c[i]-d[i-1]) mx = c[i]-d[i-1];
	}
	cout << "Yes" << endl;
	rep(i,n) {
		cout << b[(i+n-mx)%n] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 25144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n,m,k,a[30][31];
int temp,ans;
signed main() {
    cin >> n >> m;
    for (int i=0;i<n;i++) {
        cin >> k;
        for (int j=0;j<k;j++) {
            cin >> temp; temp--;
            a[i][temp] = 1;
        }
    }
    for (int j=0;j<n;j++) {
        for (int i=0;i<m;i++) {
            a[0][i] &= a[j][i];
        }
    }
    for (int i=0;i<m;i++) {
        ans += a[0][i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = map(int, input().split())

def how_many_times_divisible(n):
    ans = 0
    while n % 2 == 0:
        n /= 2
        ans += 1
    return ans
 

ans = min(map(how_many_times_divisible, a))
 
print(ans)

Measured memory_bytes: 2940
import java.util.Scanner;

class Main {

	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int K=stdIn.nextInt();
		int z=0,y=0;
		while(z<K) {
			if(A%2==1) {
				A-=1;
				B+=A/2;
				A/=2;
			}
			else {
				B+=A/2;
				A/=2;
			}
			z++;
			if(z==K)
				break;
			if(B%2==1) {
				B-=1;
				A+=B/2;
				B/=2;
			}
			else {
				A+=B/2;
				B/=2;
			}
			z++;
		}
		System.out.println(A+" "+B);
	}
}

Measured memory_bytes: 23892
n,k=map(int,input().split())
TD=[]
for i in range(n):
  t,d=map(int,input().split())
  TD.append([t,d])
TD.sort(key=lambda x:x[1],reverse=True)
V=set()
S=[]
ans=0
for t,d in TD[:k]:
  ans+=d
  if t in V:
    S.append(d)
  else:
    V.add(t)
ans+=len(V)**2
x=ans
for t,d in TD[k:]:
  if S==[]:
    break
  if not t in V:
    x=x-S.pop()+d-len(V)**2+(len(V)+1)**2
    V.add(t)
    ans=max(x,ans)
print(ans)

Measured memory_bytes: 22980
#include <stdio.h>
#include <math.h>

int main(void) {
    int a, b;
    scanf("%d%d", &a, &b);
    if(ceil((double)(a + b) / 2) == floor((double)(a + b) / 2)) {
        printf("%d\n", (a + b) / 2);
    } else {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())
L = []
for i in range(N):
  L.append(list(map(int, input().split())))
L = sorted(L,key = lambda x:x[0])

ans = 0
i = 0
while M:
  if L[i][1] < M:
    ans += L[i][0] * L[i][1]
    M -= L[i][1]
  else:
    ans += L[i][0] * M
    M = 0
  i += 1
  
print (ans)

Measured memory_bytes: 29796