akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for(int i = s; i < (e); ++i)
#define FASTIO                                                                                     \
	ios_base::sync_with_stdio(false);                                                              \
	cin.tie(NULL);
#define FILEIO                                                                                     \
	freopen("./input.txt", "r", stdin);                                                            \
	freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                                                  \
	for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;  \
		debug("%s : %lld ms\n ",                                                                   \
			  d,                                                                                   \
			  chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() -   \
														  blockTime.first)                         \
				  .count()),                                                                       \
			 blockTime.second = false)
const int M = 1e9 + 7;

template <class T>
T ABS(const T& x) {
	return x > 0 ? x : -x;
}
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }
ll ceil2(ll a, ll b) { return (a + b - 1) / b; }

int main() {
	FASTIO
#ifdef LOCAL
	FILEIO
#endif
	ll n, k;
	cin >> n >> k;

	ll ans = 0;
	if(k == 0) {
		cout << n * n << endl;
		return 0;
	}
	for(ll b = k + 1; b <= n; ++b) {
		ll lidx = ((n - k) / b) + 1;
		ll last = k + (lidx - 1) * b;
		ans += (lidx - 1) * (b - k);
		ans += min(n, last + (b - k - 1)) - last + 1;
		// cout << b << " " << lidx << " " << last << " " << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
import java.io.*;

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

        int n = Integer.parseInt(br.readLine());
        String[] str = br.readLine().split(" ");
        long[] num = new long[n];
        for(int i=0; i<n; i++){
            num[i] = Long.parseLong(str[i]);
        }
        int min = 0, max = 0;
        long sum = num[0];
        for(int i=1; i<n; i++){
            sum += num[i];
            if(num[i] < num[min]){
                min = i;
            }else if(num[i] > num[max]){
                max = i;
            }
        }
        sb.append(num[min]).append(" ").append(num[max]).append(" ").append(sum).append("\n");

        System.out.print(sb);



    }
}

Measured memory_bytes: 28384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  ll n,m;
  cin >> n >> m;
  ll ans = 0;
  if(m <= 2*n){
    cout << m/2 << endl;
    return 0;
  }
  cout << n + (m - 2*n)/4 << endl;
}

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

int main() {
	int r;
	cin>>r;
	if(r<1200){
		cout<<"ABC";
	}
	else if(r<2800){
		cout<<"ARC";
	}
	else{
		cout<<"AGC";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n,i,j;
    scanf("%d", &n);
    long int a[n];
    for(i=0; i<n; i++)
    {
     scanf("%ld",&a[i]);
    }
    long int t=a[0];
    long int sum=0;
    for(i=1;i<n;i++){
        if(t>a[i]){
            sum=sum+t-a[i];
            t=t;
        }
        else{
            t=a[i];
        }
 
    }
    printf("%ld\n",sum);
   
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
#include <string.h>
#define ll long long int
using namespace std;
int main()
{
 string a,b;
 cin>>a>>b;
 int i,j,k,ans=INT_MAX;
 for(i=0;i<=(a.size()-b.size());i++)
 {int d=0;
     string c=a.substr(i,b.size());
    // cout<<c<<endl;
     for(j=0;j<b.size();j++)
     {
         if(c[j]!=b[j])
         d++;
     }
     ans=min(ans,d);
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 3640
N, Y = map(int,input().split())
for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if x*10000 + y*5000 + z*1000 == Y and z >= 0:
            print(x,y,z)
            quit()

print("-1 -1 -1")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()
int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++){
   cin >> d.at(i);
  }
  int result = 0;
  for(int i = 0; i < N - 1; i++){
   for(int j = i + 1; j < N; j++){
    result += d.at(i) * d.at(j);
   }
  }
  cout << result << endl;
  
}

Measured memory_bytes: 256
import sys, collections
sys.setrecursionlimit(10000)
R, G, B, N = [int(_) for _ in input().split()]

cd = collections.defaultdict
memo = cd(lambda: cd(int))


def dfs(res, color):
    if res < 0:
        return 0
    elif res == 0:
        return 1
    elif memo[res][color] == 0:
        if color == 0:
            memo[res][color] = dfs(res - R, 0) + dfs(res - G, 1) + dfs(
                res - B, 2)
        elif color == 1:
            memo[res][color] = dfs(res - G, 1) + dfs(res - B, 2)
        elif color == 2:
            memo[res][color] = dfs(res - B, 2)
    return memo[res][color]


print(dfs(N, 0))


Measured memory_bytes: 6892
# スタート地点からDFSで大きい順に入れていけば、最も大きい数以外は得点を得られる

N = int(input())
E = [[] for i in range(N)]
for i in range(N-1):
  a,b = map(int,input().split())
  E[a-1].append(b-1)
  E[b-1].append(a-1)

# 得点を大きい順に並べる
C = sorted(list(map(int,input().split())))[::-1]

ans = [-1 for i in range(N)] # -1は未訪問
point = sum(C[1:])

from collections import deque
q = deque([])
q.append(0)
ind = 0
while q:
  v = q.popleft()
  if ans[v] != -1:
    # 訪問済み
    continue
  ans[v] = C[ind]
  ind += 1
  if ind == len(C):
    break
  children = E[v]
  for child in children:
    q.append(child)
  
print(point)  
print(*ans)

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

#define P pair<double, double>
const int N_MAX = 1010;
struct edge { ll to; double cost; };
vector<edge> adj[N_MAX];
double d[N_MAX];
ll N, M;

void dijkstra(ll s) {
  priority_queue<P, vector<P>, greater<P>> q;
  fill_n(d, N+2, LLINF); d[s] = 0; q.push(P(0, s));
  while (!q.empty()) {
    P p = q.top(); q.pop();
    ll v = p.second;
    for (auto e: adj[v]) {
      if (d[e.to] > d[v]+e.cost) {
        d[e.to] = d[v]+e.cost;
        q.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  double xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt;
  cin >> N;
  double pos[N+2][3];
  pos[0][0] = xs, pos[0][1] = ys, pos[0][2] = 0;
  pos[N+1][0] = xt, pos[N+1][1] = yt, pos[N+1][2] = 0;
  rep(i,N) cin >> pos[i+1][0] >> pos[i+1][1] >> pos[i+1][2];
  rep(i,N+2) for(int j=i+1; j<N+2; j++) {
    double d = sqrt(pow(pos[i][0]-pos[j][0],2)+pow(pos[i][1]-pos[j][1],2));
    double r = pos[i][2]+pos[j][2];
    double tmp = max((double)0, d-r);
    adj[i].push_back({j,tmp});
    adj[j].push_back({i,tmp});
  }
  dijkstra(0);
  // rep(i,N+2) { for (auto x: adj[i]) cout << x.to << ":" << x.cost << " "; cout << endl; }
  double result = d[N+1];
  cout << fixed << setprecision(10) << result << endl;
  return 0;
}

Measured memory_bytes: 22676
#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 lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
int main()
{
	string s;
	cin>>s;
	int ans=0;
	int n=s.size();
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='?')
			s[i]='D';
	}
	cout<<s;
}



Measured memory_bytes: 3756
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

#define NMAX 1000000

signed main(){

    int N,K;

    int A[2000];

    cin>>N>>K;

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

    sort(A,A+N);

    int ans=0;
    for(int i=0;i<K;i++){
        ans+=A[i];
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
int n, m, e, f, g, ans;
int r[15];
int k[10];
int s[10][10];
int p[10];
int b[10];
int main() {
	r[0] = 1;
	for (int i = 0; i < 12; i++) {
		r[i + 1] = r[i] * 2;
	}
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", k + i);
		for (int j = 0; j < k[i]; j++) {
			scanf("%d", &s[i][j]);
			s[i][j]--;
		}
	}
	for (int i = 0; i < m; i++) {
		scanf("%d", p + i);
	}
	for (int i = 0; i < r[n]; i++) {
		e = i;
		g = 1;
		for (int j = 0; j < n; j++) {
			b[j] = e % 2;
			e /= 2;
		}
		for (int j = 0; j < m; j++) {
			f = 0;
			for (int h = 0; h < k[j]; h++) {
				if (b[s[j][h]])f++;
			}
			if ((f % 2) != (p[j] % 2))g = 0;
		}
		ans += g;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
N, K = map(int, input().split())

ma = (N-1)*(N-2)//2
if K > ma:
    print(-1)
else:
    X = []
    for i in range(1, N):
        X.append((0, i))
    for i in range(1, N):
        for j in range(i+1, N):
            if K == ma:
                break
            X.append((i, j))
            K += 1
        if K == ma:
            break
    print(len(X))
    for a, b in X:
        print(a+1, b+1)


Measured memory_bytes: 44784
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
 
using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
 
int main()
{
#if LOCAL_ENVIRONMENT == 1
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  ll N = input();
  vector<ll> A,B,C;

  for(ll i=0;i<N;i++){
    ll a = input();
    ll b = input();
    ll c = input();

    A.push_back(a);
    B.push_back(b);
    C.push_back(c);
  }

  ll dp[N][3];
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;
  for(ll i=1;i<=N;i++){
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + A[i-1];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + B[i-1];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + C[i-1];
  }

  output(max(max(dp[N][0],dp[N][1]),dp[N][2]));

  return 0;
}

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

Measured memory_bytes: 2088
import sys

def solve():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    A = [[int(a) for a in input().split()] for _ in range(H)]
    Ans = []
    for n in range(H * W - 1):
        h, w = n // W, n % W
        if A[h][w] % 2 == 1:
            if w < W - 1:
                Ans.append((h+1, w+1, h+1, w+2))
                A[h][w] -= 1
                A[h][w+1] += 1
            else:
                Ans.append((h+1, w+1, h+2, w+1))
                A[h][w] -= 1
                A[h+1][w] += 1
    print(len(Ans))
    for move in Ans:
        print(" ".join(map(str, move)))
   
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 26124
n, m = map(int, input().split())
ls_ab = [[int(_) for _ in input().split()] for _ in range(m)]

ls_ans = [0]*n

for i in range(n):
    for j in range(m):
        if i+1 in ls_ab[j]:
            ls_ans[i] += 1

for k in range(n):
    print(ls_ans[k])

Measured memory_bytes: 3060
#include <iostream>
#include <string> 
using namespace std;
string s,t;
int main(){
	int k=0;
	char x;
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		for(int j=0;j<t.size();j++){
			if(s[j]!=t[j]){
				x=s[s.size()-1];
				for(int p=s.size()-1;p>0;p--){
					s[p]=s[p-1];
				}
				s[0]=x;
				k=1;
				break;
			}
		}
		if(k==0){
			cout<<"Yes";
			return 0;
		}
		k=0;
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)

ll sq(ll x){
	return x*x;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; i--){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	char c;
	cin >> c;
	cout << ((isvowel(c)?"vowel":"consonant")) << endl;
	return 0;
}

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

int main() {
 int N;
 string seged;
 vector <string> pls_kill_me;
 cin >> N;
 for(int i=0;i<N;i++){
  cin >> seged;
  pls_kill_me.push_back(seged);
 }
 int AC=0;
 int WA=0;
 int TLE=0;
 int RE=0;
 for(int i=0;i<N;i++){
   if(pls_kill_me[i]=="AC"){
     AC+=1;
   }else if(pls_kill_me[i]=="WA"){
   WA+=1;
  
 }else if(pls_kill_me[i]=="TLE"){
   TLE+=1;
 }else if(pls_kill_me[i]=="RE"){
   RE+=1;
 }
 }
 cout << "AC x "<<AC<<endl ;
 cout << "WA x "<<WA<<endl ;
 cout << "TLE x "<<TLE<<endl ;
 cout << "RE x "<<RE<<endl ;
	return 0;
}


Measured memory_bytes: 7448
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main{
	static Scanner sc = new Scanner(System.in);

	static int height;

	static int width;

	static char[][] map;

	public static void main(String[] args) {

		while (true) {
			height = sc.nextInt();
			width = sc.nextInt();
			if (height == 0 && width == 0) {
				break;
			}
			map = new char[height][];

			for (int i = 0; i < height; i++) {
				map[i] = sc.next().toCharArray();
			}
			int cnt = 0;
			Deque<int[]> s = new ArrayDeque<>();
			for (int i = 0; i < height; i++) {

				for (int j = 0; j < width; j++) {
					char target;
					if (map[i][j] == '@' || map[i][j] == '#' || map[i][j] == '*') {
						s.add(new int[] { i, j });
						target = map[i][j];
					} else {
						continue;
					}
					while (!s.isEmpty()) {
						int[] u = s.poll();

						int[] dx = { 1, 0, 0, -1 };
						int[] dy = { 0, 1, -1, 0 };
						for (int d = 0; d < 4; d++) {
							int nx = u[0] + dx[d];
							int ny = u[1] + dy[d];
							if (0 > nx || nx >= height || 0 > ny || ny >= width) {
								continue;
							}
							if (map[nx][ny] == target) {
								map[nx][ny] = '.';
								s.add(new int[] { nx, ny });
							}

						}

					}
					cnt++;
				}

			}
			System.out.println(cnt);
		}
	}

}

Measured memory_bytes: 30984
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>

int main(void){
    int i,j,k;
    int N;
    int answer;
    
    scanf("%d",&N);
    
    answer = N * N * N;
    
    printf("%d\n",answer);
    
    return 0;
}













Measured memory_bytes: 128
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"1"# => r#"1"#,
r#"2"# => r#"2"#,
r#"3"# => r#"2"#,
r#"4"# => r#"4"#,
r#"5"# => r#"4"#,
r#"6"# => r#"4"#,
r#"7"# => r#"4"#,
r#"8"# => r#"8"#,
r#"19"# => r#"16"#,
r#"20"# => r#"16"#,
r#"100"# => r#"64"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
    }

    let s = [1,2,4,8,16,32,64];
    let a:Vec<_> = s.iter().filter(|&&i| i <= n).collect();
    a[a.len() - 1].to_string()
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
  int N, M, C;
  cin >> N >> M >> C;
  int X, nc = 0, B[M], A[M][N];
  
  for (int i = 0; i < M; i++){
    cin >> B[i];
  }
  
  for (int j = 0; j < N; j++){
    for (int i = 0; i < M; i++){
      cin >> A[i][j];
    }
  }
  

  for (int j = 0; j < N; j++){
    X = 0;
    for (int i = 0; i < M; i++){
      X += B[i] * A[i][j];
    }
    if( X > -C) nc++;
  }
  
  cout << nc << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){

  int a, b, c, z;

  cin >> a >> b >> c;  

  if (a < b){
    a < b;
  } else {  
    z = a, a = b, b = z;
  }

  if (b < c){
    b < c;
  } else {
    z = b, b = c, c = z;
  }

  if (a < b){
    a < b;
  } else {
    z = a, a = b, b = z;
  }

  cout << a << " " << b << " " << c << "\n";

  return 0;
 }

Measured memory_bytes: 1164
#include <algorithm>
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;
using ll = long long;

int main()
{
    int n;
    while( cin >> n ){
        vector<int>v(n);
        int now = 1;
        int cnt = 0;
        for( int i = 0; i < n; i++ ){
            int a; cin >> a;
            if( a == now ){
                now++;
            }else{
                cnt++;
            }
        }
        if( cnt == n ){
            cnt = -1;
        }
        cout << cnt << "\n";
    }
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int home1[][] = new int[3][10];
		int home2[][] = new int[3][10];
		int home3[][] = new int[3][10];
		int home4[][] = new int[3][10];
		for(int i = 0; i < n; i++){
			int b = s.nextInt();
			int f = s.nextInt();
			int r = s.nextInt();
			int v = s.nextInt();
			if(b == 1) home1[f - 1][r - 1] = home1[f - 1][r - 1] + v;
			if(b == 2) home2[f - 1][r - 1] = home2[f - 1][r - 1] + v;
			if(b == 3) home3[f - 1][r - 1] = home3[f - 1][r - 1] + v;
			if(b == 4) home4[f - 1][r - 1] = home4[f - 1][r - 1] + v;
		}
		for(int a = 0; a < 4; a++){
			for(int i = 0; i < 3; i++){
				for(int j = 0; j < 10;j++){
					
						if (a == 0) System.out.print(" " + home1[i][j]);
						else if(a == 1) System.out.print(" " + home2[i][j]);
						else if(a == 2) System.out.print(" " + home3[i][j]);
						else if(a == 3) System.out.print(" " + home4[i][j]);
	
				}
				System.out.println();
			}
			if(a != 3) System.out.println("####################");
		}
	}

	public static void main(String[] args) {
		/* 
		 * Main x;
		 * x = new Main();
		 * x.run();
		 * ??¨????????????
		 */
		new Main().run();
		
	}
}

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

int main(){
	int a,b,c,d,tr,bu;
	cin>>a>>b>>c>>d;
	tr=(a>b)?b:a;
	bu=(c>d)?d:c;
	cout<<tr+bu<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int h, m, s, n;
    
    scanf("%d", &n);
    
    s = n % 60;
    m = n / 60 % 60;
    h = n / (60*60);
    
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
    
}



Measured memory_bytes: 2072
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ni()
a_array = na()
cnt = [0] * 3
for a in a_array:
    cnt[a-1] += 1

dp = [[[0] * (N+1) for _ in range(N+1)] for _ in range(N+1)]

for sushi in range(1, N+1):
    for k in range(sushi+1):
        for j in range(0, sushi-k+1):
            i = sushi-k-j
            if i != 0:
                dp[i][j][k] += dp[i-1][j][k] * i / sushi
            if j != 0:
                dp[i][j][k] += dp[i+1][j-1][k] * j / sushi
            if k != 0:
                dp[i][j][k] += dp[i][j+1][k-1] * k / sushi
            dp[i][j][k] += N / sushi

print(dp[cnt[0]][cnt[1]][cnt[2]])


Measured memory_bytes: 368024
#include <bits/stdc++.h>
using namespace std;
int N,M;
vector<vector<int>> relat(9,vector<int>(9,0));
vector<int> Flag(9,0);
int Count = 0;
bool all1(vector<int> flag){
    for(int i=1;i<=N;i++){
        if(flag[i] == 0) return false;
    }
    return true;
}

void dfs(int n,vector<int> flag){
    vector<int> vec = flag;
    vec[n] = 1;
    int check = 0;
    for(int i=1;i<=N;i++){
        if(relat[n][i]==1 && vec[i]!=1){
            dfs(i,vec);
            check = 1;
        }
    }
    if(check==0 && all1(vec)) Count++;
    return;
}

int main(){
    cin >> N >> M;
    for(int i=1;i<=M;i++){
        int a,b;
        cin >> a >> b;
        relat[a][b] = 1;
        relat[b][a] = 1;
    }
    dfs(1,Flag);
    cout << Count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll mod=1000000007;

int n;
string a,b;

int main()
{
	cin>>n;
	cin>>a>>b;
	
	ll ans=1;
	ll cur=-1;
	for(int i=0;i<n;i++){
		if(a[i]==b[i]){
			if(cur==-1){
				ans*=3;
				ans%=mod;
			}
			else if(cur==0){
				ans*=2;
				ans%=mod;
			}
			cur=0;
		}
		else{
			if(cur==-1){
				ans*=6;
				ans%=mod;
			}
			else if(cur==0){
				ans*=2;
				ans%=mod;
			}
			else{
				ans*=3;
				ans%=mod;
			}
			cur=1;
			i++;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $a, $b);
$loop = 1;
$multi = 1;
$greater = max($a,$b);
$less = min($a,$b);
while($loop === 1) {
    if(($greater * $multi) % $less === 0) {
    $loop = 0;
    break;
    } else {
        $multi++;
    }
}
echo $greater * $multi;

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}



int main()
{
        ll N;
        cin >> N;
        vll D(N);
        rep(i, 0, N) cin >> D[i];
        ll M;
        cin >> M;
        vll T(M);
        rep(i, 0, M) cin >> T[i];

        sort(all(D));
        sort(all(T));
        ll j = 0;

        bool ans = false;
        rep(i, 0, N) {
                if (j >= M) break;
                if (T[j] == D[i]) {
                        ++j;
                }
        }
        if (j == M) ans = true;
        
        if (ans) {
                cout << "YES" << endl;
        } else {
                cout << "NO" << endl;
        }
}


Measured memory_bytes: 6440
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

vector<int> G[100010];
int H[100010];

int main() {
	int N, M, a, b;
	cin >> N >> M;
	for (int i = 0;i < N;i++) {
		cin >> H[i];
	}
	for (int i = 0;i < M;i++) {
		cin >> a >> b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	bool gd;
	a = 0;
	for (int i = 0;i < N;i++) {
		gd = 1;
		for (auto j : G[i]) {
			if (H[j] >= H[i])gd = 0;
		}
		if (gd)a++;
	}
	cout << a << endl;
}

Measured memory_bytes: 9164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, N) {
		if (A[i] % 2 == 0 && A[i] % 3 != 0&&A[i]%5!=0) {
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
}


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

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

	if (a <= 0 && 0 <= b) {
		puts("Zero");
		return 0;
	}

	if (a > 0) {
		puts("Positive");
	} else {
		if ((b - a + 1) % 2 == 0) {
			puts("Positive");
		} else {
			puts("Negative");
		}
	}
}

Measured memory_bytes: 256
N = int(input())
A = tuple(map(int, input().split()))

money = 1000
stock = 0
for i in range(N - 1):
    if A[i] < A[i + 1]:
        stock += money // A[i]
        money %= A[i]
    else:
        money += stock * A[i]
        stock = 0
money += stock * A[-1]
stock = 0
print(money)


Measured memory_bytes: 9176
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 3001; //N+1
int W_MAX = 3001; //W+1
typedef pair<int,int> P;
int main()
{
  int n,w,i,j;
  int v[N_MAX][W_MAX];
  P ww[N_MAX];
  cin >> n >> w;
  for(i=1;i<=n;i++)
    cin >> ww[i].first >> ww[i].second;
  sort(ww+1,ww+n+1,greater<P>());
  v[0][0]=0;
  fill(v[0]+1,v[0]+w+1,-1);
  for(i=1;i<=n;i++){
    v[i][0]=0;
    v[i][1]=max(ww[i].second,v[i-1][1]);
    for(j=2;j<=w;j++)
      if(j<=ww[i].first||v[i-1][j-ww[i].first]==-1){
        v[i][j]=v[i-1][j];
      }else{
        v[i][j]=max(v[i-1][j],v[i-1][j-ww[i].first]+ww[i].second);
      }
  }
  cout << *max_element(v[n],v[n]+w+1) << endl;
  return 0;
}

Measured memory_bytes: 38772
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

inline ll floor(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return a / llb;
	}
	else
	{
		return - ( (-a + llb - 1) / llb);
	}
}

inline ll ceil(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return (a + llb - 1) / llb;
	}
	else
	{
		return - (-a / llb);
	}
}

inline bool isPower2(ull a)
{
	if (a == 0)
	{
		return false;
	}
	return !(a & (a - 1));
}

inline ll getMaxEffectiveBit(ull a)
{
	ll index = -1;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

inline ll getSpecifiedBit(ull a, unsigned bit)
{
	return (a & (1LL << bit)) >> bit;
}

// computational complexity: o(log(max(a, b))) 
inline ull getGcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

template<class Integer>
inline Integer getPower(Integer base, ull exponential)
{
	Integer result = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			result = result * base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return result;
}

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

	ll N, D;
	cin >> N >> D;
	
	vector<vector<ll>> Xs(N, vector<ll>(D));
	for (ll i = 0; i < N; ++i)
	{
		for (ll j = 0; j < D; ++j)
		{
			cin >> Xs[i][j];
		}
	}

	ll res = 0;
	for (ll i = 0; i < N; ++i)
	{
		for (ll j = i + 1; j < N; ++j)
		{
			ll dist = 0;
			for (ll d = 0; d < D; ++d)
			{
				dist += (Xs[i][d] - Xs[j][d]) * (Xs[i][d] - Xs[j][d]);
			}
			if (dist == ll(sqrt(dist)) * ll(sqrt(dist)) )
			{
				++res;
			}
		}
	}

	cout << res << endl;

	return 0;
}


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

int main(){

	int H, W;

	cin >> H >> W;

	while( H != 0 && W != 0){					//W=0とH=0になるまで繰り返す
		for(int i = 0; i < H; i++){				//縦軸に[＊]を増やして行く
			for(int j = 0; j < W; j++){			//横軸に[＊]を増やして行く
				cout << ".#"[j==0 || j == W-1 || i == 0 || i == H-1];
			}
			cout << endl ;
		}
		cout << endl;
		cin >> H >> W;
	}

	return 0;
}


Measured memory_bytes: 3048
def Levenshtein(s:str, t:str) -> int:
	ls, lt = len(s), len(t)
	dp = [[0]*(lt+1) for _ in range(ls+1)]
	dp[0] = list(range(lt+1))
	for i in range(ls+1):
		dp[i][0] = i
	for i,a in enumerate(s):
		for j,b in enumerate(t):
			if a==b:
				dp[i+1][j+1] = dp[i][j]
			else:
				dp[i+1][j+1] = min(dp[i][j], dp[i+1][j], dp[i][j+1]) + 1
	return dp[ls][lt]
	
def solve():
	print(Levenshtein(input(),input()))
	
if __name__=="__main__":
	solve()


Measured memory_bytes: 41852
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
const int maxn = 1e4+10;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
char c[maxn];
int main(){
	scanf("%s",c+1);
	n=strlen(c+1);
	printf("%c%d%c",c[1],n-2,c[n]);
	return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=2e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll ans=0;
        f(i,1,n)
        {
            f(j,1,n)
            {
                f(k,1,n)
                {
                    ans+=__gcd(__gcd(i,j),k);
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
















Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
    int w, n, i, temp, a, b;
    scanf("%d", &w);
    scanf("%d", &n);

    int x[w];
    for(i=0; i<w; i++)
        x[i] = i+1;

    for(i=0; i<n; i++) {
        scanf("%d,%d", &a, &b);
        temp = x[a-1];
        x[a-1] = x[b-1];
        x[b-1] = temp;
    }

    for(i=0; i<w; i++)
        printf("%d\n",x[i]);

    return (0);
}

Measured memory_bytes: 596
#include <stdio.h>
int main(){
int a;
int b;

scanf("%d",&a);
scanf("%d",&b);

if (a==b){
printf("a == b\n");
}

if (a>b){
printf("a > b\n");
}

if(a<b) printf("a < b\n");

return 0;

}


Measured memory_bytes: 2100
#include <iostream>

inline int myABS( int v )
{
	return ( v > 0 ? v : -v );
}

int main()
{
	int x1, x2, y1, y2;
	int x3, x4, y3, y4;
	std::cin >> x1 >> y1 >> x2 >> y2;

	if ( x1 >= x2 )
	{
		if ( y1 >= y2 )
		{
			x3 = x2 + myABS( y1 - y2 );
			y3 = y2 - myABS( x1 - x2 );

			x4 = x3 + myABS( y2 - y3 );
			y4 = y3 + myABS( x2 - x3 );
		}
		else
		{
			x3 = x2 - myABS( y1 - y2 );
			y3 = y2 - myABS( x1 - x2 );

			x4 = x3 + myABS( y2 - y3 );
			y4 = y3 - myABS( x2 - x3 );
		}
	}
	else
	{
		if ( y1 >= y2 )
		{
			x3 = x2 + myABS( y1 - y2 );
			y3 = y2 + myABS( x1 - x2 );

			x4 = x3 - myABS( y2 - y3 );
			y4 = y3 + myABS( x2 - x3 );
		}
		else
		{
			x3 = x2 - myABS( y1 - y2 );
			y3 = y2 + myABS( x1 - x2 );

			x4 = x3 - myABS( y2 - y3 );
			y4 = y3 - myABS( x2 - x3 );
		}
	}

	std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << std::endl;

	return ( 0 );
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n+1), b(n);
    ll cnt=0;

    for(ll i=0; i<n+1; i++) cin >> a[i];
    for(ll i=0; i<n; i++) cin >> b[i];

    // a 0 ~ n
    // b 0 ~ n-1

    for(ll i=0; i<n; i++) {
        if(a[i]+a[i+1] >= b[i]) {
            cnt += b[i];
            if(a[i] < b[i]) a[i+1] += a[i] - b[i];
        } else {
            cnt += a[i] + a[i+1];
            a[i+1] = 0;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int dp[2][(1<<24)];
string s[511];
int n,m;
bool a[511][511];
int ans1=0;
int List[510];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  while(cin>>n>>m,n|m){
    for(int i=0;i<n;i++){
      cin>>s[i];
      for(int j=0;j<m;j++){
        a[i][j]=(s[i][j]=='1');
      }
    }
    ans1=0;
    if(n<=m){
      for(int i=0;i<(1<<n);i++){
        bool ok=1;
        for(int j=0;j<m;j++){
          int cont=0;
          for(int k=0;k<n;k++){
            if((i>>k)&1 && a[k][j])++cont;
          }
          if(cont&1){
            ok=0;
            break;
          }
        }
        if(ok)ans1=max(ans1,__builtin_popcount(i));
      }
    }else{
      fill(List,List+n,0);
      for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
          if(a[i][j]){
            List[i]=List[i]|(1<<j);
          }
        }
      }
      for(int i=0;i<2;i++)for(int j=0;j<(1<<m);j++)dp[i][j]=-1;
      dp[0][0]=0;
      for(int i=0;i<n;i++){
        for(int j=0;j<(1<<m);j++)dp[(i+1)&1][j]=-1;
        for(int j=0;j<(1<<m);j++){
          if(dp[i&1][j]==-1)continue;
          dp[(i+1)&1][j^List[i]]=max(dp[(i+1)&1][j^List[i]],dp[i&1][j]+1);
          dp[(i+1)&1][j]=max(dp[(i+1)&1][j],dp[i&1][j]);
        }
      }
      ans1=dp[n&1][0];
    }
    cout<<ans1<<endl;
  }
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}







Measured memory_bytes: 19684
#include "bits/stdc++.h"
using namespace std;

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

	if (a <= 5) {
		cout << 0;
	}
	else if (a <= 12) {
		cout << b / 2;
	}
	else {
		cout << b;
	}

	return 0;

}

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

ll ar[200005];
ll total[200005];
ll rtotal[200005];

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

    ll test=1;
    //cin>>test;
    while(test--)
    {
        ll n,k;
        cin>>n>>k;

        for(ll i=0;i<=n;i++)
        {
            ar[i]=i;
        }

        total[0]=0;

        for(ll i=1;i<=n;i++)
        {
            total[i]=total[i-1]+ar[i];
        }

        rtotal[n]=n;
        
        for(ll i=n-1;i>=0;i--)
        {
            rtotal[i]=rtotal[i+1]+ar[i];
        }

        // for(ll i=0;i<=n;i++)
        // cout<<total[i]<<' ';
        // cout<<endl;

        // for(ll i=n;i>=0;i--)
        // cout<<rtotal[i]<<' ';
        // cout<<endl;

        ll ans=0;
        ll p=n-k+1;
        for(ll i=k-1;i<=n;i++)
        {
            ans+=(rtotal[p]-total[i]+1);
            p--;
        }

        cout<<ans%MOD;
    }
}

Measured memory_bytes: 8228
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli a, b;
    cin>>a>>b;
    lli A=0, B=0;
    rep(i,a){
            A += b * pow(10, i);
    }
    rep(i,b){
        B += a * pow(10, i);
    }
    vec(string) s;
    s.push_back(to_string(A));
    s.push_back(to_string(B));
    sort(all(s));
    out(s[0]);
}

Measured memory_bytes: 4252
/*
 * Author:  heyuhhh
 * Created Time:  2020/6/21 20:05:07
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#include <functional>
#include <numeric>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

ll mpow[N];

void run() {
    ll n; cin >> n;
    ll cnt = 0, t = 0;
    int k;
    mpow[0] = 1;
    for (int i = 1;; i++) {
        mpow[i] = mpow[i - 1] * 26;
        cnt += mpow[i];
        if (cnt >= n) {
            t = cnt - mpow[i];
            k = i;
            break;
        }
    }
    string res = "";
    for (int i = 1; i <= k; i++) {
        for (int j = 0; j < 26; j++) {
            if (t + mpow[k - i] < n) {
                t += mpow[k - i];
            } else {
                res += (j + 'a');
                break;
            }
        }
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize ("O2") // "Ofast" for REAL FAST
// #pragma GCC optimization ("unroll-loops")

// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#include <bits/stdc++.h>
#define DEBUG 1

using namespace std;

#define rep(i, a, b) for (i = (a); i < (b); i++)
#define trav(a, x) for (auto & a : x)
#define all(x) (x).begin (), (x).end ()
#define sz(x) (int) (x).size ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;

typedef pair <int, int> pii;
#define f first
#define s second
#define mp(x, y) make_pair (x, y)

typedef vector <int> vi;
#define pb(x) push_back (x)

#define ddcout if (DEBUG) cout
#define ddprintf(fmt, ...) if (DEBUG) printf (fmt, ##__VA_ARGS__)

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x3f3f3f3f3f3f3f3f;
const int  INFi  =  0x3f3f3f3f;
const ll   MAXN  =  54001; // UPDATE

int main ()
{
    FASTIO;
    int i, j, good = 0;
    vi val (MAXN, 0);
    scanf ("%d", &j);
    for (i = 0; i < j + 1 && !good; i++)
        if ((int)(i*1.08) == j)
            good = 1;
    if (!good)
        printf (":(\n");
    else
        printf ("%d\n", i - 1);

    return 0;
}


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

int N;
int x[10],y[10];

double dist(int i,int j){
  double d1 = x[i]-x[j];
  double d2 = y[i]-y[j];
  return pow(d1*d1+d2*d2,0.5);
}

int fact(int n){
  if (n == 1) return 1;
  else return n*fact(n-1);
}

int main(){
  cin >>N;
  for(int i=0;i<N;i++) cin >>x[i]>>y[i];
  
  double ans = 0;
  
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      ans += dist(i,j);
    }
  }
  double sum = 0;
  vector<int> v(N);
  for(int i=0;i<N;i++) v[i] = i;
  do{
    for(int i=0;i<N-1;i++){
      sum += dist(v[i],v[i+1]);
    }
  } while(next_permutation(v.begin(),v.end()));
  cout << setprecision(10) << sum/fact(N) << endl;
}

Measured memory_bytes: 384