akhauriyash/Code-Regression huggingface dataset:
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define N 500055
#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int ans,n,m,x,a[N],sum;
signed main(){
	n=read();x=read();
	F(i,1,n) a[i]=read(),sum+=a[i];
	sort(a+1,a+n+1);
	F(i,1,n){
		if (x>=a[i]) x-=a[i],ans++;
	}
	if (ans==n&&x!=0) ans--;
	wrn(ans);
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef map<int, int> mii;
    typedef map<char,int> mci;
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef vector<ll> vll;
    typedef vector<pair<int,int>> vii;
    typedef vector<char> vc;
    typedef vector<vc> vcc;
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()
    #define pb push_back
    #define mp make_pair
    #define F first
    #define S second
    #define in insert
    #define sz(v) v.size()
    #define mina(a,b) (a)=min((a),(b));
    #define maxa(a,b) (a)=max((a),(b));
    const int INF = 1e9 + 5;
    void solve(){
        int n,p; cin>>n>>p;
        cout<<(n*3+p)/2;
    }
    int main(){
        int T=1;
        //cin>>T;
        for(int i = 0; i < T; i++) solve(); 
    }

Measured memory_bytes: 256
let n = Scanf.scanf " %d" (+) 0
let vs = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let cs = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let _ = Array.mapi (fun i v -> if cs.(i) < v then v - cs.(i) else 0) vs |> Array.fold_left (+) 0 |> Printf.printf "%d\n"

Measured memory_bytes: 384
A=["k","e","y","e","n","c","e"]
f=-1;p=0;q=0;r=0
S=list(map(str,input()))
if S[0:7]==A or S[len(S)-7:len(S)]==A:
  f=1
else:
  if S[0]!=A[0]:
    f=0
  else:    
    for i in range(len(S)):
      if S[i]==A[i]:
        p=p+1
      else:
        if A[0:p]+S[len(S)-(len(A)-p):len(S)]==A:
          #print(A[0:p]+S[len(S)-(len(A)-p):len(S)])
          f=1
          break
        else:
          f=0
          break
print("YES" if f==1 else "NO")

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
using namespace std;

int main(){
	char a[100000], b[100000];
	scanf("%s", a);
	scanf("%s", b);
	int lena = strlen(a);
	int lenb = strlen(b);
	if(lena > lenb) printf("GREATER\n");
	else if(lenb > lena) printf("LESS\n");
	else{
		if(strcmp(a,b) > 0) printf("GREATER\n");
		else if(strcmp(a,b) == 0) printf("EQUAL\n");
		else printf("LESS\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
vector<pair<int,int> >x;
int m;
for(int i=0;i<n;i++){
  cin>>m;
  x.push_back(make_pair(m,i+1));
}
sort(x.begin(),x.end());
for(int i=0;i<n;i++){
  cout<<x[i].second<<" ";
}
cout<<endl;
  return 0;
}


Measured memory_bytes: 1780
def main():
    N,K = map(int,input().split())
    a = N // K
    N = N - a * K
    while True:
        N2 = abs(N - K)
        if N2 < N:
            N = N2
        elif N2 >= N:
            break
    print(int(N))


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define N 100000 + 5
#define M 15
#define inf 10000000000000000
#define int long long
#define rep(i, l, r) for(int i = l; i <= r; ++i)
char ch[M];
int n, len, a[N], op[N], dp[N][3];
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
signed main(){
    n = read();
    rep(i, 1, 2 * n - 1){
        if(i & 1) a[i / 2 + 1] = read();
        else{
            scanf("%s", ch + 1);
            if(ch[1] == '+') op[i / 2 + 1] = 1;
            else op[i / 2 + 1] = 2;
        }
    }
    dp[1][0] = a[1], dp[1][1] = dp[1][2] = -inf;
    rep(i, 2, n){
        if(op[i] == 1){
            dp[i][0] = dp[i - 1][0] + a[i];
            dp[i][0] = max(dp[i][0], dp[i - 1][1] - a[i]);
            dp[i][0] = max(dp[i][0], dp[i - 1][2] + a[i]);
            dp[i][1] = dp[i - 1][1] - a[i];
            dp[i][1] = max(dp[i][1], dp[i - 1][2] + a[i]);
            dp[i][2] = dp[i - 1][2] + a[i];
        }
        else{
            dp[i][0] = dp[i - 1][0] - a[i];
            dp[i][0] = max(dp[i][0], dp[i - 1][1] + a[i]);
            dp[i][0] = max(dp[i][0], dp[i - 1][2] - a[i]);
            dp[i][1] = dp[i - 1][1] + a[i];
            dp[i][1] = max(dp[i][1], dp[i - 1][2] - a[i]);
            dp[i][1] = max(dp[i][1], dp[i - 1][0] - a[i]);
            dp[i][2] = dp[i - 1][2] - a[i];
            dp[i][2] = max(dp[i][2], dp[i - 1][1] + a[i]);
        }
    }
    printf("%lld", dp[n][0]);
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, k;
    std::cin >> n >> k;
    int ret = 0;
    for (int i = 0; i < n; i++) {
        int in;
        std::cin >> in;
        if (in >= k) ret++;
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
# -coding: utf-8 -

a = int(input())
b = int(input())
c = int(input())
x = int(input())

s = a + b + c
#ans = []
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            money = 500*i+100*j+50*k
#            print(money)
            if money == x:
                count += 1
#                strs = str(i)+str(j)+str(k)
#                ans.append(strs)
      
print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
#define MAX 200000

int main()
{
	int n;
	long long int l[MAX];
	int i, j;
	long long int total1 = 0;
	long long int total2 = 0;
	long long int total3;
	long long int total4;
	long long int total=0;
	cin >> n;

	for (i = 0; i < n; i++)
	{
		scanf("%lld",&l[i]);
		total = total + l[i];
	}

	//	for (i = 0; i < n; i++)
	//	{
	//		cout << l[i]<<endl;
	//	}

	for (i = 0; i < n - 1; i++)
	{
		total1 = total1 + l[i];
		//cout << "total1은" << total1 << endl;
		
		total2 = total - total1;
		//cout << "total2은" << total2 << endl;
		if (i == 0)
		{
			total3 = abs(total1 - total2);
			total4 = total3;
			//	cout << "total3은" << total3 << endl;
		}
		else
		{
			total4 = abs(total1 - total2);
		}
		if (total4 < total3)
		{
			total3 = total4;
			//	cout << "total3은" << total3 << endl;
		}
		

	}


	cout << total3;

	return 0;
}

Measured memory_bytes: 1792
#D
import bisect
N,T,Q = map(int,input().split())
AD = [list(map(int,input().split())) for i in range(N)]
X = [int(input()) for i in range(Q)]

wall = []
for i in range(N-1):
    a1,d1 = AD[i]
    a2,d2 = AD[i+1]
    
    if d1 == 1 and d2 == 2:
        if T > (a2-a1)//2:
            wall.append((a1+a2)//2)
        
wlen = len(wall)
for x in X:
    ind = x-1
    a,d = AD[ind]
    if d == 1:
        bind = bisect.bisect_left(wall,a)
        if bind == wlen:
            print(a+T)
        else:
            wa = wall[bind]
            if wa <= a+T:
                print(wa)
            else:
                print(a+T)
    else:
        bind = bisect.bisect_left(wall,a)-1
        if bind == -1:
            print(a-T)
        else:
            wa = wall[bind]
            if wa >= a-T:
                print(wa)
            else:
                print(a-T)
        





Measured memory_bytes: 21136
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<time.h> 
#define debug(a) cout << "*" << a << "*" << endl
#define ls	(k << 1)
#define rs	((k << 1) | 1)
#define mid	((l + r) >> 1)
using namespace std;
typedef long long ll;
ll a[55], m, n;
int main()
{
	while (~scanf("%lld", &m))
	{
		//m = low(1, m, m);
		memset(a, 0, sizeof(a)); 
		printf("50\n");
		n = m % 50;
		m /= 50;
		for (int i = 0; i < n; i++)	a[i] = 50;
		if (m)
			for (int i = 0; i < 50; i++) a[i] += (49 - n + m);
		for (int i = 0; i < 50; i++)	printf("%lld%c", a[i], i == 49 ? '\n' : ' ');
	} 
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split() ))
n = 0

leave = False
while True:
    for i in range(N):
        if A[i]% 2 == 1:
            leave = True
    if leave == True:
        break
    n += 1
    A = list(map(lambda x : x/2, A))
    
print(n)

Measured memory_bytes: 2940
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

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

int main()
{
	int h, m, s;
	while(scanf("%d%d%d", &h, &m, &s), h!=-1){
		int rest = 120*60 - (h*60*60 + m*60 + s);
		printf("%02d:%02d:%02d\n", rest/3600, rest%3600/60, rest%60);
		rest *= 3;
		printf("%02d:%02d:%02d\n", rest/3600, rest%3600/60, rest%60);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
int main(){
int x, h, m ,s;
std::cin >> x;
s = x % 60;
x = x - s;
x = x / 60;
m = x % 60;
x = x - m;
h = x / 60;
std::cout << h << ":" << m << ":" << s << std::endl;
}


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

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


#define ll long long 
#define ld long double
#define pb push_back
#define F first
#define S second
#define I insert
#define pll pair<ll,ll> 
#define vll vector<ll> 
#define vpll vector< pll >

int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll a,b,c,d,i,j,k,n;
	cin>>n;vll bit;
	for(i=0;i<20;i++){
		if(((1<<i)&n)>0)bit.pb(i);
	}
	vector<pair<pll,ll > > ed;a=*(--bit.end());b=1<<a;
	ll biv[25];c=a;ll on,om;on=a+1;b>>=1;
	trace(a);ll ca=a;
	for(i=1;i<=(ca);i++){
		trace(i);
		ed.pb({{i,i+1},b});
		ed.pb({{i,i+1},0});
		biv[a]=i;a--;b>>=1;
	}
	biv[a]=i;
	d=bit.size();ll cur=1<<(bit[d-1]);
	for(i=d-2;i>=0;i--){
		a=bit[i];trace(a);ed.pb({{1,biv[a]},cur});
		cur+=1<<bit[i];
	}
	// ed.pb({{1,on},n});
	cout<<on<<" "<<(ed.size())<<"\n";
	for(auto z:ed){
		cout<<z.F.F<<" "<<z.F.S<<" "<<z.S<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
// AOJ 2407: Simple Othello
// 2017.11.28 bal4u@uu

#include <stdio.h>
#include <string.h>

char buf[55];

int main()
{
	scanf("%s", buf);
	puts(*buf == 'x' && *(buf+strlen(buf)-1) == 'x' ? "x" : "o");
	return 0;
}

Measured memory_bytes: 1820
#include <stdio.h>

int main(void){
	int N, D, ans;
	scanf("%d %d", &N, &D);
	ans = N % (D * 2 + 1) == 0 ? N / (D * 2 + 1) : N / (D * 2 + 1) + 1;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

double dist( double x1, double y1, double x2, double y2 ){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main(){
	double x1, y1, x2, y2, x3, y3;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
	double a = dist(x1, y1, x2, y2);
	double b = dist(x2, y2, x3, y3);
	double c = dist(x3, y3, x1, y1);
	double d = max({a, b, c});
	double S = abs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))/2;
	double R = S*2/(a+b+c);
	cout << fixed << setprecision(12) << d/(d/R+2) << endl;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  atcoder174
//
//  Created by Keita on 2020/08/02.
//  Copyright © 2020 Keita. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

void doProblemA(){
    int X;
    cin >> X;
    if(X >= 30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

int main(int argc, const char * argv[]) {
    // insert code here...
    doProblemA();
    return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<map>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<utility> 
#include<fstream>
#include<cassert>
#include<cstdlib>
#include<deque>
#include<list>
#include<bitset>
#include<cassert>
#include<functional>
using namespace std;
int n,dp[100005],la[100005],pre[200005],va[200005],deg[100005];
//vector<int> nei[100005];
void dfs(int v,int pa)
{
	int cnt=0;
	for(int i=la[v];i!=-1;i=pre[i])
	{
		int u=va[i];
		if(u==pa) continue;
		dfs(u,v);
		if(dp[u]==0) cnt++;else dp[v]+=dp[u];
	}
	if(cnt>1) dp[v]+=cnt-1;
	dp[v]=max(dp[v],0);
}
int main()
{
	cin>>n;
	memset(la,-1,sizeof(la));
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		pre[2*i]=la[x];
		va[2*i]=y;
		la[x]=2*i;
		pre[2*i+1]=la[y];
		va[2*i+1]=x;
		la[y]=2*i+1;
		deg[x]++;deg[y]++;
	}
	bool flag=0;
	int ro=-1;
	for(int i=0;i<n-1;i++)
	{
		if(deg[i]>=3) ro=i; 
	}
	if(ro==-1)
	{
		cout<<1;
		return 0;
	}
	dfs(ro,-1);
	cout<<dp[ro];
}

Measured memory_bytes: 6528
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    char[] S = sc.next().toCharArray();
    int n = S.length;
    char a = S[0];
    char b = S[n - 1];

    if (a == b && n % 2 == 1 || a != b && n % 2 == 0) {
      System.out.println("Second");
    } else {
      System.out.println("First");
    }
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else 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;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		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() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 9684
import fractions

def LCM(a,b):
    return int(a*b/fractions.gcd(a,b))

if __name__=="__main__":
    A,B,C,D=map(int,input().split())
    lcm=LCM(C,D)
    count=B//C+B//D-B//lcm
    count1=(A-1)//C+(A-1)//D-(A-1)//lcm
    result=B-A+1-count+count1
    print(int(result))

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

int main(void){
        int H1,M1,H2,M2,K;
        int cul;
        int ans;
        cin>>H1>>M1>>H2>>M2>>K;

        cul=(H2*60+M2)-(H1*60+M1);

        if(cul>K){
                ans=cul-K;
        }else{
                ans=0;
        }
        cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 3580
'use strict'


const yakusuu = (N) => {
    let count = 0
    for(let i = 0; i <= N; i++) {
        if(N % i === 0) {
            count++;
        }
    }
    return count
}

const Main = (input) => {
    const N = Number(input)
    let count = 0;
    for(let i = 0; i <= N; i++) {
        if(i % 2 === 0) {
            continue;
        }
        if(yakusuu(i) === 8) {
            count++;
        }
    }
    console.log(count)
}


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

Measured memory_bytes: 21064
from collections import defaultdict
N,M=map(int,input().split())
B=[list(map(int,input().split())) for _ in range(M)]
dic=defaultdict(list)
ans="IMPOSSIBLE"
for i,j in B:
  dic[i].append(j)
O=dic.get(1)
if N in O:
    ans="POSSIBLE"
for o in O:
  T=dic.get(o)
  try:
    if N in T:
      ans="POSSIBLE"
  except:
    pass
print(ans)

Measured memory_bytes: 66916
#include <stdio.h>
#include <math.h>
#include <limits.h>

int main(){
  int weight;
  int i, k, cnt;
  int flag[10] = {0};
  while(scanf("%d", &weight) != EOF){
    cnt = 0;
    for(i=31;i>=0;i--){
      k = weight & (~INT_MAX);
      if(k != 0){
	flag[i] = 1;
	cnt++;
      }else if(i<10){
	flag[i] = 0;
      }
      weight <<= 1;
    }
    for(i = 0;i <10;i++){
      if(cnt == 1 && flag[i] == 1){
	printf("%d\n", (int)pow(2, i));
	break;
      }
      if(flag[i] == 1){
	printf("%d ", (int)pow(2, i));
	cnt--;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 636
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0) 
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

#define MID(a,b,c) (a) <= (b) && (b) <= (c)

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n,m,a,b,c,d,x,y,z;
  string s,t;
  //

  // ここから
  IN(s);
  int num1 = stoll(s.substr(0,2));
  int num2 = stoll(s.substr(2,2));
  if(MID(1,num1,12) && MID(1,num2,12)) OUT("AMBIGUOUS");
  else if(MID(1,num1,12)) OUT("MMYY");
  else if(MID(1,num2,12)) OUT("YYMM");
  else OUT("NA");
}

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

int main(){
  int k;
  string s;
  cin >> k >> s;
  if((int)(s.size()) <= k){
    cout << s << endl;
  }
  else{
    for(int i=0;i<k;i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3572
#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()
{
    ll h;
    cin >> h;
    int cnt = 0;
    while (h)
    {
        cnt++;
        h /= 2;
    }
    ll ans = (ll)pow(2, cnt) - 1;
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> c(n);
  bool f = true;
  int p = n-1;
  for(int i=0; i<n; ++i){
    cin >> c[i];
    if(f && c[i] >=0){
      f = false;
      p = i;
    }
  }
  ll x = min(p+k-1, n-1);
  ll plus = max(0,c[x]), minus = - min(0,c[x-k+1]);
  ll ans = min(plus *2 +minus, minus *2 +plus);
  //cout << "m:" << minus << " p:" << plus << " ans:" << ans << endl;
  for(int i=x; i>=p && i-k>=0; --i){
    plus -= c[i] - max(0, c[i-1]);
    minus -= c[i-k] -min(0, c[i-k+1]);
    ll tot = min(plus *2 +minus, minus *2 +plus);
    //cout << "m:" << minus << " p:" << plus << " tot:" << tot << endl;
    ans = min(ans, tot);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3776
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	set<int> A;

	A.insert(a);
	A.insert(b);
	A.insert(c);

	cout << A.size() << endl;


}






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


int main() {
  int n;
  string s,t;
  cin  >> n >> s >> t;
  rep(i,n) cout << s.at(i) << t.at(i);
  cout << endl;
}

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

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 184467440737095516;

struct info
{
	ll weight, val;
};

ll n, w, cnt, sum, memo[100100][105];
info arr[100100];

ll dp(ll x, ll idx){
	ll ret1 = 0;
	ll ret2 = 0;
	if (x == 0){
		return 0;
	}
	if (idx > n){
		return 0;
	}
	if (memo[x][idx] != -1){
		return memo[x][idx];
	}
	if (arr[idx].weight <= x){
		ret1 = dp(x - arr[idx].weight, idx + 1) + arr[idx].val;
	}
	ret2 = dp(x, idx + 1);
	ll maxi = max(ret1, ret2);
	memo[x][idx] = maxi;
	return maxi;
}

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

	memset(memo, -1, sizeof(memo));
	cin >> n >> w;
	for (ll i = 1; i <= n; i++){
		cin >> arr[i].weight >> arr[i].val;
	}
	cout << dp(w, 1) << '\n';
}
  

Measured memory_bytes: 82432
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    if(N % 2 == 0){
        int sum = 0;
        rep(i,0,N/2)sum ^= V[i*2];
        rep(i,0,N/2){
            int tmp = sum ^ V[i*2];
            if(V[i*2] != tmp){
                cout << "No" << endl;
                return 0;
            }
        }
        sum = 0;
        rep(i,0,N/2)sum ^= V[i*2+1];
        rep(i,0,N/2){
            int tmp = sum ^ V[i*2+1];
            if(V[i*2+1] != tmp){
                cout << "No" << endl;
                return 0;
            }
        }
    }else{
        int sum = 0;
        rep(i,0,N)sum ^= V[i];
        rep(i,0,N){
            int tmp = sum ^ V[i];
            if(V[i] != tmp){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;

    vector<pii> LR;  // [L, R)
    LR.emplace_back(0, 0);
    for (int i = 0; i < N; i++) {
        if (S[i] == '1') {
            int j = i;
            while (S[j] == '1') ++j;
            LR.emplace_back(i, j);
            i = j - 1;
        }
    }
    LR.emplace_back(N, N);

    //for (auto p : LR) cout << p.first << " " << p.second << endl;
    // 尺取り
    int res = 0;
    int r = 0;
    for (int l = 0; l < LR.size(); l++) {
        while (r < LR.size() && r - l <= K) ++r;
        res = max(res, LR[r - 1].second - LR[l].first);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#define inf 2100000001
using namespace std;

bool vis[1005][1005];//标记是否入过队 
int d[1005][1005];//最少次数 
deque<pair<int,int> > q;
string s[1005];//地图 

int main(){
	int h,w,ch,cw,dh,dw;
	cin>>h>>w>>ch>>cw>>dh>>dw;
	ch--; cw--; dh--; dw--;
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	for(int i=0;i<h;i++){//初始化 
		for(int j=0;j<w;j++)
		    d[i][j]=inf;
	}
	
	q.push_back(pair<int,int>(ch,cw));//起点入队 
	d[ch][cw]=0;
	vis[ch][cw]=true;
	
	while(!q.empty()){//宽搜 
		pair<int,int> a=q.front(); 
		int x=a.first,y=a.second;
		if(dh==x&&dw==y){
			cout<<d[x][y]<<endl;
			return 0;
		}
		vis[x][y]=true;
		q.pop_front();
		
		for(int i=-2;i<=2;i++){//将规定区域内符合要求的未入队的点入队 
			for(int j=-2;j<=2;j++){
				int xx=x+i,yy=y+j;
				if(xx>=0&&xx<h&&yy>=0&&yy<w&&s[xx][yy]=='.'){
					if(vis[xx][yy]) continue;
					if(abs(i)+abs(j)<2){//如果该点原点的邻点 
						q.push_front(pair<int,int>(xx,yy));
					    d[xx][yy]=d[x][y];
					    vis[xx][yy]=true;
					}
					else{
					    if(d[x][y]+1<d[xx][yy]){
						    d[xx][yy]=d[x][y]+1;//松弛优化 
						    q.push_back(pair<int,int>(xx,yy));
					    }
				    }
				}
			}
		}
	}
	
	cout<<"-1"<<endl;
	return 0;
} 

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

VI edge[(int)1e5+2];
bool used[(int)1e5];
deque<int> ans;

void dfs(int current, bool backFlag){
  for(int node : edge[current]){
    if(used[node]) continue;
    used[node] = true;
    if(backFlag) ans.push_back(node);
    else ans.push_front(node);
    dfs(node,backFlag);
    break;
  }
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin >> n >> m;
  int a,b;
  rep(i,m){
    cin >> a >> b;
    a--, b--;
    edge[a].push_back(b);
    edge[b].push_back(a);

  }
  // a,b には最後に追加された辺が格納されている
  used[a] = true, used[b] = true;
  ans.push_front(a);
  dfs(a,false);
  ans.push_back(b);
  dfs(b,true);
  cout << ans.size() << endl;
  while(ans.empty() == false){
    int node = ans.front();
    ans.pop_front();
    if(ans.empty()) cout << node+1 << endl;
    else cout << node+1 << " ";
  }

  return 0;
}


Measured memory_bytes: 9344
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	N, M = MAP()
	S = input()

	pos_0 = []
	for i in range(N+1):
		if S[i] == "0":
			pos_0.append(i)

	q = deque([])
	pos = N
	while pos != 0:
		next_pos = pos-M
		idx = bisect_left(pos_0,next_pos)
		if pos-pos_0[idx] > M or pos == pos_0[idx]:  # 移動できない
			print(-1)
			exit()

		q.appendleft(pos-pos_0[idx])
		pos = pos_0[idx]

	print(*q)


if __name__ == '__main__':
	main()


Measured memory_bytes: 12368
#include <iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if ((x<=W-r)&&(x>=r)&&(y<=H-r)&&(y>=r)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3108
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let N: usize = sc.read();
    let A: usize = sc.read();
    let B: usize = sc.read();
    let mut s = vec![0; 3];
    for i in 0..N {
        let p: usize = sc.read();
        if p <= A {
            s[0] += 1;
        } else if p <= B {
            s[1] += 1;
        } else {
            s[2] += 1;
        }
    }
    println!("{}", cmp::min(s[2], cmp::min(s[0], s[1])));
}

Measured memory_bytes: 2064
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

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

  double l;
	cin >> l;
  double a = l/3;
	cout << fixed << setprecision(15) << a * a * a << "\n";
}


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


def check(s):
    for i in range(len(s)-1):
        if(abs(int(s[i])-int(s[i+1])) > 1):
            return len(s)-i-2
    return -1


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

    if k < 10:
        print(k)
        return

    c = 10
    s = '1'
    table = [0] * (10**5+5)
    while c <= k+1:
        d = check(s)
        if d != -1:
            s = str(int(s)+10**d)
            continue
        last = int(s[-1])
        if last != 0:
            table[c] = s+str(last-1)
            c += 1
        table[c] = s+str(last)
        c += 1
        if last != 9:
            table[c] = s+str(last+1)
            c += 1
        s = str(int(s)+1)

    print(table[k])


main()


Measured memory_bytes: 56524
// ****IMP DP PROBLEM****
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
ll dp[25][100005];
ll n,a[200000];
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	ll l;
	cin>>l;
	for(int i=0;i<n;i++)//init
	{
		dp[0][i]=upper_bound(a,a+n,a[i]+l)-a-1;
	}
	for(int k=1;k<=22;k++)
	{
		for(int i=0;i<n;i++)
		{
			dp[k][i]=dp[k-1][dp[k-1][i]];
		}
	}
	tc(T)
	{
		ll x,y;
		cin>>x>>y;
		x--;
		y--;
		if(x>y) swap(x,y);
		ll ans=0;
		for(int k=22;k>=0;k--)
		{
			if(dp[k][x]<y)
			{
				ans+=(1<<k);
				x=dp[k][x];
			}
		}
		cout<<ans+1<<endl;
	} 
	return 0;
}
// we are basically assuming the steps to be k
// then we try to fill the set bits in k
// we compute dp[k][i] which denote the coordinate of the position that we 
// reach if we jump 2^k steps from i
// this way we can say that if kth bit is set or not
// we do this for every bit ...

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

using namespace std;

typedef long long ll;

inline ll read(){
	char ch=getchar();ll x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

char c[101001];

int a[101001];

ll n;

int main(){
	cin>>c+1;
	ll n=read();
	int l=strlen(c+1);
	for(int i=1;i<=l;i++){
		a[i]=c[i]-'0';
	}
	for(int i=1;i<=n;i++){
		if(a[i]==1) continue;
		else {
			printf("%d\n",a[i]);
			return 0;
		}
	}
	cout<<1<<' ';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	fastio
	float a,b,c,i,j;
	cin>>a>>b>>c;
	i=a/c;
	if(b-i>=0)
	{
		cout<<"Yes\n";
	}
	else
		cout<<"No\n";
	return 0;
}
	

Measured memory_bytes: 3732
import math
import functools
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))
def gcd(A, B):
  while(True):
    if A and B:
      if A > B:
        A = A % B
      else:
        B = B % A
    else:
      return max(A, B)

def lcm(A, B):
  return (A // gcd(A, B)) * B

print(functools.reduce(lcm, sorted(T, reverse=True)))


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int get_gcd(int a, int b){
	while(b>0){
		int t = a % b;
		a = b;
		b = t;
	}
	return a;
}


int main(){
	int n,K;
	int a[200000];
	cin>>n>>K;
	int maximum = 0;
	int gcd = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		maximum = max(maximum, a[i]);
		gcd = get_gcd(gcd, a[i]);
	}
	if ((K%gcd == 0) && (K<=maximum) ) cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> Q;

const int inf1=1e9+9;
const ll inf2=1e16+9;
const ll mol=1e9+7;
const int maxn=1e3+9;
const ll maxx=1e12+9;

int m,n,si,sj,ei,ej;
char ar[maxn][maxn];
int di[33],dj[33];
int adi[4]={0,1,0,-1},adj[4]={1,0,-1,0};
int vis[maxn][maxn];
vector<P> point,tmp;

void bfs(int pi,int pj,int steps)
{
    if(vis[pi][pj]!=-1) return;
    tmp.push_back(P(pi,pj));
    vis[pi][pj]=steps;
    queue<P> que; que.push(P(pi,pj));
    while(!que.empty())
    {
        P p=que.front(); que.pop();
        int ii=p.fir,jj=p.sec;
        for(int k=0;k<4;k++)
        {
            int ni=ii+adi[k],nj=jj+adj[k];
            if(0<=ni&&ni<n&&0<=nj&&nj<m&&ar[ni][nj]=='.'&&vis[ni][nj]==-1)
                vis[ni][nj]=steps,que.push(P(ni,nj)),tmp.push_back(P(ni,nj));
        }
    }
}
int main()
{
    scanf("%d%d%d%d%d%d",&n,&m,&si,&sj,&ei,&ej); getchar();
    si--,sj--,ei--,ej--;
    for(int i=0;i<n;i++) scanf("%s",ar[i]);
    for(int i=-2,len=0;i<=2;i++)
        for(int j=-2;j<=2;j++)
            di[len]=i,dj[len++]=j;
    memset(vis,-1,sizeof vis);
    point.push_back(P(si,sj));
    int steps=0;
    while(!point.empty())
    {
        for(int i=0;i<point.size();i++) bfs(point[i].fir,point[i].sec,steps);
        point.clear();
        for(int i=0;i<tmp.size();i++)
        {
            for(int k=0;k<25;k++)
            {
                int ni=tmp[i].fir+di[k],nj=tmp[i].sec+dj[k];
                if(0<=ni&&ni<n&&0<=nj&&nj<m&&ar[ni][nj]=='.'&&vis[ni][nj]==-1) point.push_back(P(ni,nj));
            }
        }
        tmp.clear();
        steps++;
    }
    printf("%d\n",vis[ei][ej]);
}


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

using namespace std;
typedef long long ll;

int main() {
  ll N; cin >> N;
  ll M; cin >> M;
  vector<ll> L(M);
  vector<ll> R(M);
  for (ll j=0; j < M; ++j) cin >> L[j] >> R[j];
  sort(L.rbegin(), L.rend());
  sort(R.begin(), R.end());
  ll ans = R[0]-L[0]+1;
  cout << (ans >= 0?ans:0) << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)
#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

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



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, M;
    string S,T;
    cin>>N>>M>>S>>T;
    
    ll g = N*M/gcd(N,M);
    ll si=0,ti=0;
    
    while(si<N && ti<M){
        if(S[si]!=T[ti]){
            cout1(-1);
            return 0;
        }
        si += g/M;
        ti += g/N;
    }
    cout1(g);
    
}

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

int main(){
    
    int N; cin >> N;
    string s; cin >> s;
    stack<char>S;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '(')S.push('(');
        else if(S.size() && S.top() == '(')S.pop();
        else S.push(')');
    }
    while(!S.empty()){
        if(S.top() == '(')s = s + ")";
        else s = "(" + s;
        S.pop();
    }
    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

void get() {

}

typedef long long ll;
ll dp[123456][5];
const ll MOD = 1e9 + 7;
class DWeLoveABC {
public:
	void solve(std::istream& in, std::ostream& out) {
		memset(dp, 0, sizeof(dp));
		string s;
		in >> s;
		int n = s.size();
		dp[0][0] = 1;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j <= 3; ++j) {
				dp[i + 1][j] += dp[i][j] * (s[i] == '?' ? 3LL : 1LL);
				dp[i + 1][j] %= MOD;
				if(j < 3 && s[i] == '?' || s[i] == "ABC"[j]) {
					dp[i + 1][j + 1] += dp[i][j];
					dp[i + 1][j + 1] %= MOD;
				}
			}
		}
//		cerr << "case one:" << '\n';
//		for (int i = 0; i < 4; ++i) {
//			for (int j = 0; j <= n; ++j) {
//				cerr << dp[i][j] << " ";
//			}
//			cerr << '\n';
//		}
		out << dp[n][3] << endl;
	}
};


int main() {
	DWeLoveABC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 5248
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, K);
    vi A{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    OUT(A[K - 1]);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 == 1)
  {
    cout << "No";
    return 0;
  }
  for (int i = 0; i < n / 2; ++i)
  {
    if (s[i] != s[i + n / 2])
    {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}


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

// #define int long long

/* short */
#define pb push_back
#define print(Target) cout << Target << '\n'

/* REPmacro */
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

/* const */
const int INF = INT_MAX;

signed main()
{
  ios::sync_with_stdio(false);
  int n, k;

  while (cin >> n >> k, n || k){
    vi s(k);
    REP(i, k) cin >> s[i];
    bool flg = true;
    REP(i, n){
      REP(j, k){
        int b;
        cin >> b;
        s[j] -= b;
        // cout << "s[" << j << "]" << s[j] << endl;
        if (s[j] < 0){
          flg = false;
        }
      }
    }
    puts(flg ? "Yes" : "No");
  }
  
  return (0);
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input();
		var h = p[0].ToLong();
		var w = p[1].ToLong();
		var t = (h*w/2);
		if(h == 1 || w == 1)
		{
			Console.WriteLine(1);
		}
		else if(t * 2 == h * w)
		{
			Console.WriteLine(t);
		
		}
		else
		{
			Console.WriteLine(t+1);
		
		}
	}
	

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 13140