akhauriyash/Code-Regression huggingface dataset:
#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 sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifndef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void solve()
{
	int a, b;
	cin >> a >> b;
	cout << a / (2 * b + 1) + !!(a % (2 * b + 1));
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3612
int main()
{
    int A[99][99] = {0}, i, j, N, t;
    char s, F[4] = "SHCD";
    scanf("%d\n", &N);
    for (i = 0; i < N; A[s][t] = 1, i++)
        scanf("%c %d\n", &s, &t);
    for (i = 0; i < 4; i++)
        for (j = 1; j < 14; j++)
            if (!A[F[i]][j])
                printf("%c %d\n", F[i], j);
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define maxx 100010
#define mp make_pair
typedef pair<int,int> ii;
int dp[maxx],visitado[maxx];
vector <int> peso;

int solve(int k){

	if(k == 0) return 0;
	if(k==1) return dp[1] = abs(peso[0] - peso[1]);
	if(visitado[k] == 1) return dp[k];
	
	visitado[k] = 1;
	dp[k] = min(solve(k-2) + abs(peso[k-2] - peso[k]),solve(k-1) + abs(peso[k-1] - peso[k]));


	return dp[k];
}
int x;
int main() {
	cin >> x;
	int n;
	for(int i = 0; i < x; i++){
		cin >> n;
		peso.push_back(n);
	}
	int ans = solve(x-1);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

int add(int a, int b) {
  return a + b - mod * (a + b >= mod);
}

int mul(int a, int b) {
  return int(1ll * a * b % mod);
}

int pwr(int a, int x) {
  if (x == 0) {
    return 1;
  }
  return mul(pwr(mul(a, a), x >> 1), (x & 1 ? a : 1));
}

int dvd(int a, int b) {
  return mul(a, pwr(b, mod - 2));
}

int sub(int a, int b) {
  return a - b + mod * (a < b);
}

void inc(int& a, int b) {
  a = add(a, b);
}

void dec(int& a, int b) {
  a = sub(a, b);
}

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

  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> pr;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    int x = a[i];
    for (int j = 2; j * j <= x; ++j) {
      int cnt = 0;
      while (x % j == 0) {
        ++cnt;
        x /= j;
      }
      if (cnt) {
        pr[j] = max(pr[j], cnt);
      }
    }
    if (x > 1) {
      pr[x] = max(1, pr[x]);
    }
  }
  int val = 1;
  for (auto it : pr) {
    int p = it.first, x = it.second;
    val = mul(val, pwr(p, x));
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    inc(ans, dvd(val, a[i]));
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N)
    cin >> P[i];

  int mn = P[0];

  int cnt=1;
  for(int i=1; i<N; ++i) {
    if (P[i] < mn) {
      mn = P[i];
      cnt++;
    } else {
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1024
from sys import exit
n = int(input())
a = list(map(int, input().split()))
b = "APPROVED"
while b == "APPROVED":
  for i in a:
    if i % 2 == 0:
      if (i % 3 == 0 or i % 5 == 0):
        b = "APPROVED"
      else:
        print("DENIED")
        exit()
  break
print(b)

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		ArrayList<ArrayList<Integer>> list = new ArrayList<>();

		for (int i = 0; i < m; i++) {
			list.add(new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");
			int k = Integer.parseInt(str[0]);
			for (int j = 1; j <= k; j++) {
				list.get(i).add(Integer.parseInt(str[j]) - 1);
			}
		}

		str = br.readLine().split(" ");

		int p[] = new int[m];
		for (int i = 0; i < m; i++) {
			p[i] = Integer.parseInt(str[i]);
		}

		int ans = 0;
		for (int i = 0; i < (1 << n); i++) {
			int swi[] = new int[m];
			for (int j = 0; j < n; j++) {
				if ((i & (1 << j)) != 0) {
					for (int k = 0; k < m; k++) {
						if (list.get(k).contains(j)) {
							swi[k]++;
						}
					}
				}
			}

			boolean flag = false;
			for (int j = 0; j < m; j++) {
				if (swi[j] % 2 != p[j]) {
					flag = true;
					break;
				}
			}

			if (!flag) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24020
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

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

    vector<int> c(n);
    c[0] = 0;
    c[1] = abs(h[0] - h[1]);

    for (int i = 2; i < n; i++) {
        c[i] = min(abs(h[i] - h[i - 1]) + c[i - 1], abs(h[i] - h[i - 2]) + c[i - 2]);
    }

    cout << c[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int tmp, i, j, k, l;

		for (i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			if(i == 0) {
				System.out.print(A[0]);
			}else {
				System.out.print(" " + A[i]);
			}
		}
		System.out.println();

		for (j = 1; j < N; j++) {
			tmp = A[j];
			k = j - 1;
			while (k >= 0 && A[k] > tmp) {
				A[k+1] = A[k];
				k--;
				A[k+1] = tmp;
			}
			for (l = 0;l < N - 1; l++) {
				System.out.print(A[l] + " ");
			}
			System.out.println(A[N-1]);
		}
	}
}


Measured memory_bytes: 30928
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;

	bool ans = false;

	for(int i = 0; i < s.size(); i++){
		if(s == t){
			ans = true;
			break;
		}

		s = s.back() + s.substr(0, s.size() - 1);
	}

	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}
//解説参考

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n;
	int a[101];
	int ans=1;
	int max=1;
	int i;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		
		if(a[i]==1)
		ans++;
		
		else{
			if(ans>max)
			max=ans;
			ans=1;
		}
	}
	if(ans>max)
	max=ans;
	
	printf("%d\n",max);
}


Measured memory_bytes: 2060
N=int(input())
dic={}
for i in range(N):
    s=input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=0
m=max(dic[i] for i in dic)
ans=[]
for j in dic:
    if dic[j]==m:
        ans.append(j)
ans.sort()
for k in range(len(ans)):
    print(ans[k])

Measured memory_bytes: 32096
N,K = map(int, input().split())
A = [int(i) for i in input().split()]

"""
切る回数は広義単調減少になる
にぶたん
"""

def is_dekiru(L):
    cnt = 0
    for a in A:
        cnt += (a + L - 1) // L - 1
    return cnt <= K

ok = 10 ** 9 + 10
ng = 0
while (ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_dekiru(mid):
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 31236
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int ans = n / 111;
    if (n % 111 != 0) {
        ans++;
    }
    cout << ans * 111 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
typedef string::const_iterator State;
string s;
int formula(State& be){
	if('0'<=*be && *be<='2'){
		int ret=*be-'0';
		be++;
		return ret;
	}
	if(*be=='-'){
		be++;
		return 2-formula(be);
	}
	if(*be=='('){
		be++;
		int a=formula(be),b;
		if(*be=='*'){
			be++;
			b=formula(be);
			be++;
			return min(a,b);
		}
		if(*be=='+'){
			be++;
			b=formula(be);
			be++;
			return max(a,b);
		}
	}
}
int main(){
	while(true){
		cin >> s;
		if(s[0]=='.') break;
		vector<int> p,q,r;
		int n=s.size(),cnt=0;
		rep(i,n){
			if(s[i]=='P') p.pb(i);
			if(s[i]=='Q') q.pb(i);
			if(s[i]=='R') r.pb(i);
		}
		rep(i,3) rep(j,3) rep(k,3){
			rep(l,p.size()) s[p[l]]='0'+i;
			rep(l,q.size()) s[q[l]]='0'+j;
			rep(l,r.size()) s[r[l]]='0'+k;
//			cout << s << " ";
			State be=s.begin();
			int ans=formula(be);
			if(ans==2) cnt++;
//			cout << ans << endl;
		}
		printf("%d\n",cnt);
/*		State be=s.begin();
		int ans=formula(be);
		cout << ans << endl;*/
	}
	return 0;
}

Measured memory_bytes: 1204
#if defined(LOCAL)
#define PROBLEM_NAME "a"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define max(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x>__y?__x:__y;})
#define min(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x<__y?__x:__y;})

void solve(istream& cin, ostream& cout) {
  string s; cin >> s;
  if (s.size() < 4 or s.substr(0, 4) != "YAKI") {
    cout << "No" << lf;
  } else {
    cout << "Yes" << lf;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
INF = 10**18
dp_use = [-INF] * 5
dp_not_use = [-INF] * 5
dp_not_use[0] = 0

for a in A:
    tmp_use = [-INF] * 5
    tmp_not_use = [-INF] * 5
    for current_dif in range(-3,2):
        if current_dif-1 >= -3:
            tmp_use[current_dif] = dp_not_use[current_dif - 1] + a
        if current_dif+1 < 2:
            tmp_not_use[current_dif] = max(dp_use[current_dif+1], dp_not_use[current_dif+1])
    dp_use = tmp_use
    dp_not_use = tmp_not_use
dif = n//2 - (n-n//2)
print(max(dp_use[dif], dp_not_use[dif]))
    
            
            
    

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

namespace procon
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var W = inputs[0];
            var H = inputs[1];
            var x = inputs[2];
            var y = inputs[3];
            var r = inputs[4];

            // ????????????true
            var left = r <= x;
            var right = x + r <= W;
            var top = y + r <= H;
            var bottom = r <= y;

            Console.WriteLine(left && right && top && bottom ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 9396
import java.util.*;
import java.io.*;
import java.text.*;

public class Main {

	public static int solve(int[] a, int[] b, int k) {
		int[] tempa = a.clone();
		for (int i = 0; i < tempa.length; i++) {
			tempa[i] %= 1 << (k + 1);
		}
		int[] tempb = b.clone();
		for (int i = 0; i < tempa.length; i++) {
			tempb[i] %= 1 << (k + 1);
		}
		Arrays.sort(tempb);
		int cnt = 0;
		for (int i = 0; i < tempa.length; i++) {
			int lowerb = (1 << k) - tempa[i];
			int upperb = (1 << (k + 1)) - tempa[i] - 1;
			int lb = bsLow(tempb, lowerb);
			int ub = bsHigh(tempb, upperb);
			if (lb <= ub)
				cnt += Math.max(ub - lb + 1, 0);
//			if(k==2)System.out.println(cnt+ " "+lb+" "+ub);
			lowerb = 3 * (1 << k) - tempa[i];
			upperb = (1 << (k + 2)) - tempa[i] - 1;
			lb = bsLow(tempb, lowerb);
			ub = bsHigh(tempb, upperb);
			if (lb <= ub)
				cnt += Math.max(ub - lb + 1, 0);
//			if(k==2)
//				System.out.println(cnt+" "+lb+" "+ub);
		}
		
		return (cnt & 1) << k;
	}

	public static int bsLow(int[] a, int key) {
		int lo = 0;
		int hi = a.length - 1;
		int ans = a.length;
		while (lo <= hi) {
			int mid = lo + hi >> 1;
			if (a[mid] >= key) {
				ans = mid;
				hi = mid - 1;
			} else
				lo = mid + 1;
		}
		return ans;
	}

	public static int bsHigh(int[] a, int key) {
		int lo = 0;
		int hi = a.length - 1;
		int ans = -1;
		while (lo <= hi) {
			int mid = lo + hi >> 1;
			if (a[mid] <= key) {
				ans = mid;
				lo = mid + 1;
			} else
				hi = mid - 1;
		}
		return ans;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < b.length; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < b.length; i++) {
			b[i] = sc.nextInt();
		}
		int ans = 0;
		for (int i = 0; i < 29; i++) {
			ans |= solve(a, b, i);
		}
		pw.println(ans);
		pw.close();

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < arr.length; i++)
				arr[i] = nextInt();
			return arr;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


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

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


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) {
    cin >> a.at(i);
  }
  int count = 0;
  while (1) {
    int b = 0;
    rep (i, n) {
      if (a.at(i) % 2 == 1) {
        b = 1;
        break;
      }
      a.at(i) /= 2;
    }
    if (b == 1) {
      break;
    }
    count++;
  }
  cout << count << endl;

}



Measured memory_bytes: 3632
// AOJ 1252: Confusing Login Names
// 2017.10.12 bal4u@uu

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

#define ABS(a) ((a)>=0?(a):-(a))

typedef struct { char *s; int w; } T;
T nm[202];
char name[202][18];
int M[20][20];

int cmp(T *a, T *b) { return strcmp(a->s, b->s); }

int distance(char *s1, int w1, char *s2, int w2)
{
    int  i, j;

    for (j = 0; j <= w1; j++) M[j][0] = j;
    for (i = 0; i <= w2; i++) M[0][i] = i;
    for (j = 1; j <= w1; j++) {
        for (i = 1; i <= w2; i++) {
            int d, min;
            d = (s1[j-1] != s2[i-1]);
            min =     M[j-1][i  ] + 1;
            if (min > M[j  ][i-1] + 1) min = M[j  ][i-1] + 1;
            if (min > M[j-1][i-1] + d) min = M[j-1][i-1] + d;
            M[j][i] = min;
        }
    }
    return M[w1][w2];
}

int check(char *s1, int w1, char *s2, int w2, int d)
{
	char *t1, *t2;

	if (ABS(w1-w2) > d) return 0;
	if (distance(s1, w1, s2, w2) <= d) return 1;

	t1 = s1, t2 = s2;
	if (d == 1) {
		if (w1 != w2) return 0;
		while (*s1 == *s2) s1++, s2++;
		if (*s1 == *(s2+1) && *s2 == *(s1+1)) return strcmp(s1+2, s2+2) == 0;
		return 0;
	}

	s1 = t1, s2 = t2; while (*s1 == *s2) s1++, s2++;
	if (*s1 == *(s2+1) && *s2 == *(s1+1)) {
		s1 += 2, s2 += 2;
		if (distance(s1, w1-(s1-t1), s2, w2-(s2-t2)) < d) return 1;
		if (w1 != w2) return 0;
		while (*s1 == *s2) s1++, s2++;
		if (*s1 == *(s2+1) && *s2 == *(s1+1)) return strcmp(s1+2, s2+2) == 0;
		return 0;
	}
	if (*s1 == *(s2+1) && *s2 == *(s1+2)) return strcmp(s1+3, s2+2) == 0;
	if (*s1 == *(s2+2) && *s2 == *(s1+1)) return strcmp(s1+2, s2+3) == 0;

	s1 = t1+w1, s2 = t2+w2;
	while (*s1 == *s2) s1--, s2--;
	if (s2 > t2 && s1 > t1 && *s1 == *(s2-1) && *s2 == *(s1-1)) {
		s1 -= 2, s2 -= 2;
		return distance(t1, s1-t1+1, t2, s2-t2+1) < d;
	}
	return 0;
}

int main()
{
	int n, d, i, j, ans;
	char buf[22];

	while (fgets(buf, 20, stdin) && *buf != '0') {
		n = atoi(buf);
		fgets(buf, 20, stdin), d = atoi(buf);
		for (i = 0; i < n; i++) {
			fgets(name[i], 17, stdin);
			nm[i].s = name[i], nm[i].w = strlen(name[i])-1, name[i][nm[i].w] = 0;
		}
		qsort(nm, n, sizeof(T), cmp);
		for (ans = 0, i = 0; i < n; i++) for (j = i+1; j < n; j++) {
			if (check(nm[i].s, nm[i].w, nm[j].s, nm[j].w, d)) {
				printf("%s,%s\n", nm[i].s, nm[j].s), ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  
  int length[N];
  
  for (int i = 0; i < N; i++) {
    length[i] = 0;
  }
  
  int p = 0;
  for (int i = 0; i < N - 1; i++) {
    if (H[i] >= H[i + 1]) {
      length[p]++;
    } else {
      p++;
    }
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, length[i]);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
bool vis[100005];
LL k;
deque<pair<LL, LL> > dq;
int main()
{
	cin >> k;
	dq.push_back(make_pair(1, 1));
	while(!dq.empty())
	{
		pair<LL, LL> x = dq.front(); dq.pop_front();
		if(!x.first) { cout << x.second << endl; return 0; }
		if(vis[x.first]) continue; vis[x.first] = true;
		dq.push_front(make_pair(x.first * 10 % k, x.second));
		dq.push_back(make_pair((x.first + 1) % k, x.second + 1));
	}
	return 0;
}

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

int main(){
int N, T;
  int cost, time;
  cost = 1010;
  int c, t;
  cin >> N >> T;
  for(int i = 0; i < N; i++){
  cin >> c >> t;
    if(t <= T && c < cost){
    cost = c;
    }
  }
  if(cost <= 1000){
  cout << cost << endl;
  }
  else cout << "TLE" << endl;
}

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

int main() {
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = 0;
  for (auto& p : mp) {
    int s = p.second;
    ans += (ll)s*(s-1)/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <cstdlib>
using namespace std;
const static int LEN_MAX = 501;

int sy = 0;
int pos = 0;
bool has_error = false;
char line[ LEN_MAX ];
int d = 0;

int get_token() {
  return sy = line[ pos++ ] ;
}

int see_next_token() {
  return line[ pos + 1 ];
}

bool cat() {
  if( sy == '\0' ) { return true; }
  if( sy == 'm' ) {
    get_token();
    if( sy == 'm' ) {
      bool state = cat();
      if( !state ) { return false; }
    }
  }

  if( sy == 'e' ) {
    get_token();
    if( sy == 'm' ) {
      bool state = cat();
      if( !state ) { return false; }
    }
  } else {
    return false;
  }

  if( sy == 'w' ) {
    get_token(); 
  } else {
    return false;
  }
  return true;
}

bool check() {
  if( cat() ) {
    if( sy == '\0') {
      return true;
    }
  }
  return false;
}

int main() {
  cin >> line;
  get_token();
  cout << ( check() ? "Cat" : "Rabbit" ) << endl;

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1140
#pragma GCC optimize("O3") 
#include<bits/stdc++.h>
#define ll      				long long int
#define vi      				vector<int>
#define ii      				pair<int,int>
#define iii     				pair<ii,int>
#define iiii    				pair<ii,ii>
#define fi      				first
#define se      				second

#define pb      				push_back
#define pob     				pop_back

#define all(x)  				x.begin(), x.end()
#define len     				length()

#define db(x)					  cout << "!!!!!! " << #x << " => " << x << "\n"

#define fori(i, s, N)     for (int i = s; i <= N; i++)
#define fd(i, s, N)     for (int i = s; i >= N; i--)
using namespace std;

void init(int precision){
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

int k,sum = 0;
int main(){
	init(10);
	cin>>k;
	for(int i = 1;i<=k;i++)
		for(int j = 1;j<=k;j++)
			for(int l = 1;l<=k;l++)
				sum+=__gcd(__gcd(i,j), l);
	cout<<sum<<"\n";
	return 0;
}

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

#define int long long

#define MOD 1000000007
int n;
string s1, s2;

int memo[500][10][10] = {};

int dp(int i, int a, int b){
    if(i == n){
        return 1;
    }

    if(memo[i][a][b] != -1){
        return memo[i][a][b];
    }

    int ans = 0;

    if(s1[i] == s2[i]){
        for(int x = 1;x <= 3;x++){
            if(x != a && b != x){
                ans = (ans + dp(i+1, x, x)) % MOD;
            }
        }
    }else{
        for(int x = 1;x <= 3;x++){
            for(int y = 1;y <= 3;y++){
                if(x != y && x != a && y != b){
                    ans = (ans + dp(i+2, x, y)) % MOD;
                }
            }
        }

    }

    return memo[i][a][b] = ans;
}


signed main(){
    cin >> n;
    cin >> s1 >> s2;

    memset(memo, -1, sizeof(memo));

    cout << dp(0, 0, 0) << endl;


    return 0;
}



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

int INF = 1e8;

char s[51][51];
int d[51][51];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int H, W;

int main()
{
  cin >> H >> W;
  rep(i, H){
    rep(j, W){
      cin >> s[i][j];
    }
  }

  int sh = 0;
  rep(i, H){
    rep(j, W){
      if (s[i][j] == '#') sh++;
    }
  }

  queue<P> que;
  rep(i, H + 1){
    rep(j, W + 1){
      d[i][j] = INF;
    }
  }
  que.push(P(1, 1));
  d[1][1] = 1;

  while(que.size()) {
    P p = que.front(); que.pop();
    if (p.first == H && p.second == W) break;
    rep(i, 4){
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if (1 <= nx && nx <= H && 1 <= ny && ny <= W && s[nx - 1][ny - 1] != '#' && d[nx][ny] == INF)
      {
        que.push(P(nx, ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }

  if (d[H][W] == INF)
  {
    cout << -1 << endl;
  }else{
    cout << H * W - sh - d[H][W] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using Order_Set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
//(order) Set.order_of_key(); (pointer) Set.find_by_order();

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff




int main()
{
    long long i,j,k,l,tst=0,ans=0, csno=0, N,M;
    string S;
    cin>>S;
    string rv = S;
    reverse(rv.begin(),rv.end());
    if(S!=rv)
    {
        cout<<"No"<<endl;
        return 0;
    }

    rv = S.substr(0,S.size()/2);
    reverse(rv.begin(),rv.end());
    if(S.substr(0,S.size()/2)==rv)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    long double a,b,c;
    cin>>a>>b>>c;
    long double x=2*(sqrtl(a*b));
    c=c-a-b;
    if(c>x)
        cout<<"Yes";
    else
        cout<<"No";
    subt;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] d = new int[101];
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      d[a]++;
    }
    int ans = 0;
    for(int i = 0; i < 101; i++) { 
      if(d[i] > 0) ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22608
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    return gcd(b, a % b);
}

fn main() {
    let n = read::<usize>();
    let x = read::<i64>();
    let mut xs = vec![0; n];
    for i in 0..n {
        xs[i] = (read::<i64>() - x).abs();
    }
    let mut g = xs[0];
    for i in 0..n {
        g = gcd(g, xs[i]);
    }
    println!("{}", g);
}


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

bool between(long long x, long long y1, long long y2) {
  if (y1 > y2) swap(y1, y2);
  y1++, y2--;
  if (y1 > y2) return false;

  while (x) {
    if (x % 3 == 1) {
      if (y2 - y1 > 3) return true;
      for (long long y = y1; y <= y2; y++)
        if (y % 3 == 1) return true;
    }

    x /= 3, y1 /= 3, y2 /= 3;
  }

  return false;
}

long long get_extra(long long x1, long long y1, long long x2, long long y2) {
  long long ans = 0, three = 1;
  for (int i = 0; i < 35; i++) {
    if (x1 / three == x2 / three && between(x1 / three, y1 / three, y2 / three)) {
      long long t = min(min(x1 % three, x2 % three) + 1, three - max(x1 % three, x2 % three));
      ans = max(ans, t);
    }

    three *= 3;
  }

  return ans;
}

long long get_dist(long long x1, long long y1, long long x2, long long y2) {
  return abs(x1 - x2) + abs(y1 - y2) + 2 * max(get_extra(x1, y1, x2, y2), get_extra(y1, x1, y2, x2));
}

int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    long long a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

    printf("%lld\n", get_dist(a - 1, b - 1, c - 1, d - 1));
  }

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int keta(int x){
	int i=0;
	while (x/pow(10,i)>=1){
		i++;
	}
	if (x==0){
		return 1;
	}
	else
	return i;
	}


int main(){
int n;
while (cin>>n){
	int count=0;
for (int i=0;i<10;i++){
    for (int j=0;j<10;j++){
	   for (int k=0;k<10;k++){
		   if (0<=n-i-j-k&&n-i-j-k<10){
			   count+=1;
		   }

		   }
	   }
	}
cout<<count<<endl;
}
	}

Measured memory_bytes: 1160
/*
    Author: isaf27 (Ivan Safonov)
*/

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll bt = 31;
const ld eps = 1e-8;
const ll INF = 1e18 + 239;
const int BIG = 2e9 + 239;
const int MOD = 1e9 + 7;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
mt19937_64 rnd(239); //(chrono::high_resolution_clock::now().time_since_epoch().count());

//constants
const int M = 2e5 + 239;
const int N = 2e3 + 239;
const int L = 19;
const int T = (1 << 18);
const int B = trunc(sqrt(M)) + 1;
const int X = 1e4 + 239;
const int A = 26;

int n, a[M], last[M], dp[M];

int32_t main()
{
    #ifdef ONPC
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    memset(last, -1, sizeof(last));
    dp[0] = 1;
    for (int i = 0; i < n; i++)
    {
        dp[i + 1] = dp[i];
        if (last[a[i]] != -1 && last[a[i]] != i - 1)
            dp[i + 1] += dp[last[a[i]] + 1];
        if (dp[i + 1] >= MOD) dp[i + 1] -= MOD;
        last[a[i]] = i;
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    ll N, K, Q;
    cin >> N >> K >> Q;

    vector<ll> v(N, 0);

    for (int i = 0; i < Q; ++i) {
        int Ai;
        cin >> Ai;
        Ai--;

        v[Ai]++;
    }

    for (int i = 0; i < N; ++i) {
        if (K - Q + v[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
typedef complex<double> P;

namespace std {
    bool operator < (const P& a, const P& b) {
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    }
}

double cross(const P& a, const P& b) {
    return imag(conj(a) * b);
}

double dot(const P& a, const P& b) {
    return real(conj(a) * b);
}

int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if(cross(b, c) > 0) return +1;
    if(cross(b, c) < 0) return -1;
    if(dot(b, c) < 0) return +2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

const double EPS = 1.0e-11;
bool check(vector<P> l1, vector<P> l2) {
    int M = l1.size(), M2 = l2.size();
    if(M != M2) return false;
    rep(i, M - 1) {
        double d1 = norm(l1[i + 1] - l1[i]);
        double d2 = norm(l2[i + 1] - l2[i]);
        if(abs(d1 - d2) > EPS) return false;
    }
    rep(i, M - 2) {
        int c1 = ccw(l1[i], l1[i + 1], l1[i + 2]);
        int c2 = ccw(l2[i], l2[i + 1], l2[i + 2]);
        if(c1 != c2) return false;
    }
    return true;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    while(cin >> N && N) {
        vector<vector<P>> lines(N + 1);
        rep(i, N + 1) {
            int M; double x_, y_;
            cin >> M;
            rep(j, M) {
                cin >> x_ >> y_;
                lines[i].push_back(P(x_, y_));
            }
        }
        vector<P> rev = lines[0]; reverse(rev.begin(), rev.end());
        REP(i, 1, N + 1) {
            bool ok = false;
            ok |= check(lines[0], lines[i]);
            ok |= check(rev, lines[i]);
            if(ok) cout << i << endl;
        }
        cout << "+++++" << endl;
    }
    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int mod = 1e9+7;
struct mint{
    ll x;
    mint(ll x=0) :x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a){
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if ((x -= a.x) < 0) x += mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const{
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));

    combination c(n+5);
    mint ans = 0;
    rep(i,n){
        if (i < k-1) continue;
        ans += c(i, k-1) * a[i];
    }
    for(int i = n-1; i >= 0; i--){
        if (i + k > n) continue;
        ans -= c(n-i-1, k-1) * a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
const int mad=1000000007;
int dp1[2005][2005];
int a[2005],b[2005];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++){
        scanf("%d",&a[i]);
    }
    for(int i=1; i<=m; i++){
        scanf("%d",&b[i]);
    }
    for(int i=0; i<=n; i++)
        for(int j=0; j<=m; j++)
            dp1[i][j]=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            dp1[i][j]=dp1[i-1][j]+dp1[i][j-1]-dp1[i-1][j-1];
            if(a[i]==b[j])
                dp1[i][j]+=dp1[i-1][j-1]+1;
            if(dp1[i][j]<0)
                dp1[i][j]+=mad;
            if(dp1[i][j]>=mad)
                dp1[i][j]%=mad;
        }
    }

    printf("%d\n",(dp1[n][m]+1)%mad);
    return 0;
}


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

typedef long long int ll;

int X, Y;
const int x = 10;
const int y = 5;
const int z = 1;

tuple<ll, ll> extgcd(ll a, ll b){
    if(b){
        ll x, y;
        tie(x, y) = extgcd(b, a%b);
        return make_tuple(y, x-a/b*y);
    }else{
        return make_tuple(1, 0);
    }
}

vector<int> solve(int a2, int b2){
    // 共に負なら解なし
    if(a2<0 && b2<0)
        return {-1, -1, -1};
    
    // 共に正となる様に構築する
    // このときa2がなるだけ大きくなるようにする（a2+b2が最小となるため）
    if(b2 < 0){
        int k = (-b2+x-z-1)/(x-z);
        a2 -= k*(y-z);
        b2 += k*(x-z);
    }else{
        int k = b2/(x-z);
        a2 += k*(y-z);
        b2 -= k*(x-z);
    }
    
     if(a2<0 || b2<0 || a2+b2>X)
        // 構築不能
        return {-1, -1, -1};
    else{
        return {a2, b2, X-a2-b2};
    }
}

int main(){
    cin >> X >> Y;
    Y /= 1000;
    
    // (x-z)*a + (y-z)*b = Y-z*Xとなる整数a, bを探す
    // gcd(x-z, y-z) | Y-z*Xなので拡張ユークリッド互除法により常に構築可能
    auto t = extgcd(x-z, y-z);
    int a2 = get<0>(t) * (Y-z*X);
    int b2 = get<1>(t) * (Y-z*X);
    
    auto ans = solve(a2, b2);
    cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
    
    return 0;
}


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

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

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAX_LEN 50
int board[MAX_LEN][MAX_LEN];
bool used[MAX_LEN][MAX_LEN];
int w,h;

bool isin(int x, int y){
  return (x>=0 && x<w && y>=0 && y<h);
}

void dfs(int x, int y){
  if( !isin(x, y) )return;
  if(used[y][x])return;
  if(board[y][x]==0)return;
  used[y][x]=true;

  dfs(x-1, y);
  dfs(x+1, y);
  dfs(x, y-1);
  dfs(x, y+1);

  dfs(x-1, y-1);
  dfs(x-1, y+1);
  dfs(x+1, y-1);
  dfs(x+1, y+1);
}

int main(){
  while(true){
    cin>>w>>h;
    if(w==0 && h==0)break;
    rep(i, MAX_LEN)rep(j, MAX_LEN){
      board[i][j]=0;
      used[i][j]=false;
    }

    rep(i, h)rep(j, w)cin>>board[i][j];

    int result=0;
    rep(i, h)rep(j, w){
      if(board[i][j]==1 && !used[i][j])result++;
      dfs(j, i);
    }

    // rep(i, h){
    //   rep(j, w)cout<<board[i][j];
    //   cout<<endl;
    // }

    cout<<result<<endl;
  }
  return 0;
}



Measured memory_bytes: 3208
/**
       ������������    ������������
		Author : Avi J Patel
		University : DA-IICT
       ������������    ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    if(a.second < b.second) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
}
int main()
{
	string s;
	cin>>s;
	ll n=s.size();
	ll k;
	cin>>k;
	ll cnt=0;
	ll cur=1;
	for(int i=0;i<n-1;i++)
	{
		if(s[i]==s[i+1])
		{
			cur++;
		}
		else
		{
			cnt+=(cur/2);
			cur=1;
		}
	}
	ll l1=1,l2=1;
	for(int i=0;i<n;i++)
	{
		if(s[i]==s[i+1])
		{
			l1++;
		}
		else
		break;
	}
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]==s[i-1])
		{
			l2++;
		}
		else
		{
			break;
		}
	}
	if(l1==n)
	{
		cout<<(k*n)/2;
		return 0;
	}
	//cout<<cnt<<" "<<l1<<" "<<l2<<endl;
	int r=l1+l2;
	cnt-=(l1/2);
	ll ans=k*cnt;
	//cout<<ans<<endl;
	if(s[n-1]==s[0])
	{
		ans+=((k-1)*(r/2));
		ans+=(l1/2);
		ans+=(l2/2);
	}
	else
	{
		ans+=(k*(l1/2));
		ans+=(k*(l2/2));
	}
	
	cout<<ans;
	return 0;
}












Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
void solve() {
    int n; cin >> n;
    int abc[n][3];
    rep(i,n) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    int dp[n][3];
    dp[0][0] = abc[0][0];
    dp[0][1] = abc[0][1];
    dp[0][2] = abc[0][2];
    for(int i=0; i <n-1; i++) {
        dp[i+1][0] = abc[i+1][0] + max(dp[i][1], dp[i][2]);
        dp[i+1][1] = abc[i+1][1] + max(dp[i][0], dp[i][2]);
        dp[i+1][2] = abc[i+1][2] + max(dp[i][1], dp[i][0]);
    }
    int ans;
    ans = max(dp[n-1][0], dp[n-1][1]);
    ans = max(ans, dp[n-1][2]);
    cout << ans;

}

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

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();
		int answer = C;
		// 聞ける回数
		int cnt = B / A;
		if(cnt < C) {
			answer = cnt;
		}
		// 出力
		prtln(answer);
	}
	public static <T> void prtln(T t) { System.out.println(t); }
}

Measured memory_bytes: 22100
#include<iostream>
#include<vector>
#include<math.h>
#include<map>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define INF int(1e9)
#define N 200000
#define MP make_pair
typedef pair<int, int> P;
typedef pair<pair<P, P>, P>PP;
int n, m, flag[N];
vector<int> edge[N];
queue<int> que;
int main()
{
	cin >> n >> m;
	--n;
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		--a; --b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	for (int i = 0; i < edge[0].size(); i++)
	{
		que.push(edge[0][i]);
	}
	while (!(que.empty()))
	{
		int now = que.front();
		que.pop();
		for (int i = 0; i < edge[now].size(); i++)
		{
			if (edge[now][i] == n)
			{
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 12400
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
using namespace std;
const int N=1e5+5;
int n,k;
int p[N],q[N],ip[N],iq[N],f[N],_f[N],a[N],b[N];
void get(int k){
	if(k==0)return;
	get(k>>1);
	fo(i,1,n)a[i]=f[f[i]];
	if(k&1)
		fo(i,1,n)f[i]=a[q[ip[iq[p[i]]]]];
	else fo(i,1,n)f[i]=a[i];
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>k;
	fo(i,1,n)cin>>p[i],ip[p[i]]=i;
	fo(i,1,n)cin>>q[i],iq[q[i]]=i;
	fo(i,1,n)f[i]=i;
	get((k-1)/6);
	if(k%6==4){
		fo(i,1,n)a[i]=f[q[i]];
		fo(i,1,n)f[i]=a[i];
	}
	if(k%6==0||k%6==5){
		fo(i,1,n)a[i]=f[q[ip[i]]];
		fo(i,1,n)f[i]=a[i];
	}
	fo(i,1,n)_f[f[i]]=i;
	if(k%6==1)fo(i,1,n)b[i]=f[p[i]];
	if(k%6==2)fo(i,1,n)b[i]=f[q[i]];
	if(k%6==3)fo(i,1,n)b[i]=f[q[ip[i]]];
	if(k%6==4)fo(i,1,n)b[i]=f[ip[i]];
	if(k%6==5)fo(i,1,n)b[i]=f[iq[i]];
	if(k%6==0)fo(i,1,n)b[i]=f[iq[p[i]]];
	fo(i,1,n)a[i]=b[_f[i]];
	fo(i,1,n)printf("%d ",a[i]);
}

Measured memory_bytes: 3968
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	if(a==b && c==d) printf("yes\n");
	else if(a==c && b==d) printf("yes\n");
	else if(a==d && c==b) printf("yes\n");
	else printf("no\n");
	
		return 0;
}



Measured memory_bytes: 2704
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a;
  cin >> a;
  if(a % 2 == 0){
    cout << a / 2 << "\n";
  }
  else{
    cout << a / 2 + 1 << "\n";
  }
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
 
const int mod = 1e+9 + 7;

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }

    long long res = 0;
    for(int d = 0; d < 60; ++d){
        long long n0 = 0, n1 = 0;
        for(int i = 0; i < N; ++i){
            if((A[i] >> d) & 1) ++n1;   // d 桁目が 1
            else    ++n0;               // d 桁目が 0
        }
        long long tmp = (1ll << d) % mod;   // 2^d
        long long n = n0 * n1 % mod;        // xor 演算を施した要素で d 桁目が 1 である個数
        tmp = tmp * n % mod;                // xor 演算を施した要素の d 桁目の総和
        res = (res + tmp) % mod;
    }
    cout << res << endl;
}

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

#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i=(a);i!=(b);++i)
#define REP(i,n) rep(i,0,n)
#define all(v) (v).begin(), (v).end()
#define rs resize
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> ii;

const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;

// lambda-expression: [] (args) -> retType { body }

void run()
{
	int N;
	cin >> N;

	bool isValid = true;

	ii lastPt = ii(0, 0);
	ll lastT = 0;

	REP(i, N) {
		ii curPt;
		ll curT;
		cin >> curT >> curPt.x >> curPt.y;
		assert(lastT < curT);

		ll dx = abs(curPt.x - lastPt.x);
		ll dy = abs(curPt.y - lastPt.y);
		ll dt = curT - lastT;

		isValid &= (dx + dy <= dt);
		isValid &= ((dt - dx - dy) % 2 == 0);

		lastPt = curPt;
		lastT = curT;
	}
	cout << (isValid ? "Yes" : "No") << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// cerr << boolalpha;
	(cout << fixed).precision(10);

	run();

	return 0;
}

Measured memory_bytes: 256